@@ -7812,5 +7812,218 @@ min_value max_value hist_type
7812
7812
部門 部門
7813
7813
部門 JSON_HB
7814
7814
DROP TABLE t1;
7815
- DELETE FROM mysql.column_stats;
7815
+ create table t1 (
7816
+ col1 varchar(10) charset utf8
7817
+ );
7818
+ set names utf8;
7819
+ select hex('б'), collation('б');
7820
+ hex('б') collation('б')
7821
+ D0B1 utf8mb3_general_ci
7822
+ insert into t1 values
7823
+ ('а'),('б'),('в'),('г'),('д'),('е'),('ж'),('з'),('и'),('й');
7824
+ analyze table t1 persistent for all;
7825
+ Table Op Msg_type Msg_text
7826
+ test.t1 analyze status Engine-independent statistics collected
7827
+ test.t1 analyze status OK
7828
+ select hex(col1) from t1;
7829
+ hex(col1)
7830
+ D0B0
7831
+ D0B1
7832
+ D0B2
7833
+ D0B3
7834
+ D0B4
7835
+ D0B5
7836
+ D0B6
7837
+ D0B7
7838
+ D0B8
7839
+ D0B9
7840
+ select json_detailed(json_extract(histogram, '$**.histogram_hb'))
7841
+ from mysql.column_stats where db_name=database() and table_name='t1';
7842
+ json_detailed(json_extract(histogram, '$**.histogram_hb'))
7843
+ [
7844
+ [
7845
+ {
7846
+ "start": "а",
7847
+ "size": 0.1,
7848
+ "ndv": 1
7849
+ },
7850
+ {
7851
+ "start": "б",
7852
+ "size": 0.1,
7853
+ "ndv": 1
7854
+ },
7855
+ {
7856
+ "start": "в",
7857
+ "size": 0.1,
7858
+ "ndv": 1
7859
+ },
7860
+ {
7861
+ "start": "г",
7862
+ "size": 0.1,
7863
+ "ndv": 1
7864
+ },
7865
+ {
7866
+ "start": "д",
7867
+ "size": 0.1,
7868
+ "ndv": 1
7869
+ },
7870
+ {
7871
+ "start": "е",
7872
+ "size": 0.1,
7873
+ "ndv": 1
7874
+ },
7875
+ {
7876
+ "start": "ж",
7877
+ "size": 0.1,
7878
+ "ndv": 1
7879
+ },
7880
+ {
7881
+ "start": "з",
7882
+ "size": 0.1,
7883
+ "ndv": 1
7884
+ },
7885
+ {
7886
+ "start": "и",
7887
+ "size": 0.1,
7888
+ "ndv": 1
7889
+ },
7890
+ {
7891
+ "start": "й",
7892
+ "end": "й",
7893
+ "size": 0.1,
7894
+ "ndv": 1
7895
+ }
7896
+ ]
7897
+ ]
7898
+ explain extended select * from t1 where col1 < 'а';
7899
+ id select_type table type possible_keys key key_len ref rows filtered Extra
7900
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 Using where
7901
+ Warnings:
7902
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < 'а'
7903
+ explain extended select * from t1 where col1 < 'в';
7904
+ id select_type table type possible_keys key key_len ref rows filtered Extra
7905
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 20.00 Using where
7906
+ Warnings:
7907
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < 'в'
7908
+ explain extended select * from t1 where col1 < 'д';
7909
+ id select_type table type possible_keys key key_len ref rows filtered Extra
7910
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 40.00 Using where
7911
+ Warnings:
7912
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < 'д'
7913
+ explain extended select * from t1 where col1 < 'ж';
7914
+ id select_type table type possible_keys key key_len ref rows filtered Extra
7915
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 60.00 Using where
7916
+ Warnings:
7917
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < 'ж'
7918
+ explain extended select * from t1 where col1 < 'й';
7919
+ id select_type table type possible_keys key key_len ref rows filtered Extra
7920
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 90.00 Using where
7921
+ Warnings:
7922
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < 'й'
7923
+ delete from t1;
7924
+ insert into t1 values
7925
+ ('"а'),('"б'),('"в'),('"г'),('"д'),('"е'),('"ж'),('"з'),('"и'),('"й');
7926
+ analyze table t1 persistent for all;
7927
+ Table Op Msg_type Msg_text
7928
+ test.t1 analyze status Engine-independent statistics collected
7929
+ test.t1 analyze status OK
7930
+ select json_detailed(json_extract(histogram, '$**.histogram_hb'))
7931
+ from mysql.column_stats where db_name=database() and table_name='t1';
7932
+ json_detailed(json_extract(histogram, '$**.histogram_hb'))
7933
+ [
7934
+ [
7935
+ {
7936
+ "start": "\"а",
7937
+ "size": 0.1,
7938
+ "ndv": 1
7939
+ },
7940
+ {
7941
+ "start": "\"б",
7942
+ "size": 0.1,
7943
+ "ndv": 1
7944
+ },
7945
+ {
7946
+ "start": "\"в",
7947
+ "size": 0.1,
7948
+ "ndv": 1
7949
+ },
7950
+ {
7951
+ "start": "\"г",
7952
+ "size": 0.1,
7953
+ "ndv": 1
7954
+ },
7955
+ {
7956
+ "start": "\"д",
7957
+ "size": 0.1,
7958
+ "ndv": 1
7959
+ },
7960
+ {
7961
+ "start": "\"е",
7962
+ "size": 0.1,
7963
+ "ndv": 1
7964
+ },
7965
+ {
7966
+ "start": "\"ж",
7967
+ "size": 0.1,
7968
+ "ndv": 1
7969
+ },
7970
+ {
7971
+ "start": "\"з",
7972
+ "size": 0.1,
7973
+ "ndv": 1
7974
+ },
7975
+ {
7976
+ "start": "\"и",
7977
+ "size": 0.1,
7978
+ "ndv": 1
7979
+ },
7980
+ {
7981
+ "start": "\"й",
7982
+ "end": "\"й",
7983
+ "size": 0.1,
7984
+ "ndv": 1
7985
+ }
7986
+ ]
7987
+ ]
7988
+ select hex(col1) from t1;
7989
+ hex(col1)
7990
+ 22D0B9
7991
+ 22D0B8
7992
+ 22D0B7
7993
+ 22D0B6
7994
+ 22D0B5
7995
+ 22D0B4
7996
+ 22D0B3
7997
+ 22D0B2
7998
+ 22D0B1
7999
+ 22D0B0
8000
+ explain extended select * from t1 where col1 < '"а';
8001
+ id select_type table type possible_keys key key_len ref rows filtered Extra
8002
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 Using where
8003
+ Warnings:
8004
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < '"а'
8005
+ explain extended select * from t1 where col1 < '"в';
8006
+ id select_type table type possible_keys key key_len ref rows filtered Extra
8007
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 20.00 Using where
8008
+ Warnings:
8009
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < '"в'
8010
+ explain extended select * from t1 where col1 < '"д';
8011
+ id select_type table type possible_keys key key_len ref rows filtered Extra
8012
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 40.00 Using where
8013
+ Warnings:
8014
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < '"д'
8015
+ explain extended select * from t1 where col1 < '"ж';
8016
+ id select_type table type possible_keys key key_len ref rows filtered Extra
8017
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 60.00 Using where
8018
+ Warnings:
8019
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < '"ж'
8020
+ explain extended select * from t1 where col1 < '"й';
8021
+ id select_type table type possible_keys key key_len ref rows filtered Extra
8022
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 90.00 Using where
8023
+ Warnings:
8024
+ Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` < '"й'
8025
+ drop table t1;
8026
+ select JSON_UNQUOTE(CONVERT('"ФФ"' using cp1251));
8027
+ JSON_UNQUOTE(CONVERT('"ФФ"' using cp1251))
8028
+ ФФ
7816
8029
# End of 10.11 tests
0 commit comments