mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
add json statistics test and change histogram column type to blob
This commit is contained in:
committed by
Sergei Petrunia
parent
2aca7b0c33
commit
79cdb535da
28
mysql-test/main/statistics_json.test
Normal file
28
mysql-test/main/statistics_json.test
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
--source include/have_stat_tables.inc
|
||||||
|
--echo #
|
||||||
|
--echo # Test that JSON is a valid histogram type and we can store JSON strings in mysql.column_stats
|
||||||
|
--echo #
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
set @save_histogram_type=@@histogram_type;
|
||||||
|
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a int NOT NULL PRIMARY KEY,
|
||||||
|
b varchar(32)
|
||||||
|
) ENGINE=MYISAM;
|
||||||
|
|
||||||
|
SET histogram_type='JSON';
|
||||||
|
SELECT @@histogram_type;
|
||||||
|
|
||||||
|
INSERT INTO t1 VALUES
|
||||||
|
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx'),
|
||||||
|
(17, 'vvvvvvvvvvvvv');
|
||||||
|
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES();
|
||||||
|
DESCRIBE mysql.column_stats;
|
||||||
|
SELECT * FROM mysql.column_stats;
|
||||||
|
|
||||||
|
set histogram_type=@save_histogram_type;
|
||||||
|
DROP TABLE t1;
|
@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv;
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
|
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram varbinary(255), PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
|
CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
|
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ STRING_WITH_LEN("histogram") },
|
{ STRING_WITH_LEN("histogram") },
|
||||||
{ STRING_WITH_LEN("varbinary(255)") },
|
{ STRING_WITH_LEN("blob") },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1071,7 +1071,8 @@ public:
|
|||||||
break;
|
break;
|
||||||
case COLUMN_STAT_HISTOGRAM:
|
case COLUMN_STAT_HISTOGRAM:
|
||||||
if (stats->histogram.get_type() == JSON) {
|
if (stats->histogram.get_type() == JSON) {
|
||||||
stat_field->store((char *) "hello_world", 11, &my_charset_bin);
|
const char* val = "{'hello': 'world'}";
|
||||||
|
stat_field->store(val, strlen(val), &my_charset_bin);
|
||||||
} else {
|
} else {
|
||||||
stat_field->store((char *) stats->histogram.get_values(),
|
stat_field->store((char *) stats->histogram.get_values(),
|
||||||
stats->histogram.get_size(), &my_charset_bin);
|
stats->histogram.get_size(), &my_charset_bin);
|
||||||
|
Reference in New Issue
Block a user