Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
307b2991
Commit
307b2991
authored
Feb 07, 2022
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix JSON statistics time format and added tests for it and server version.
parent
34564587
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
21 deletions
+14
-21
mysql-test/main/mysqldump-system.result
mysql-test/main/mysqldump-system.result
+6
-5
mysql-test/main/mysqldump-system.test
mysql-test/main/mysqldump-system.test
+3
-2
sql/opt_histogram_json.cc
sql/opt_histogram_json.cc
+5
-14
No files found.
mysql-test/main/mysqldump-system.result
View file @
307b2991
...
...
@@ -23,16 +23,17 @@ create table mysql.tz like mysql.time_zone_transition;
alter table mysql.tz engine=innodb;
insert into mysql.tz select * from mysql.time_zone_transition;
set global innodb_stats_persistent=1;
set time_zone="+03:00";
SET TIMESTAMP= UNIX_TIMESTAMP('2022-01-07 07:07:00');
ANALYZE TABLE mysql.tz PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
mysql.tz analyze status Engine-independent statistics collected
mysql.tz analyze status OK
delete from mysql.index_stats where prefix_arity!=1;
delete from mysql.column_stats where column_name!='Time_zone_id';
set time_zone="+03:00";
update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz";
update mysql.column_stats set histogram=json_replace(histogram, '$.collected_
at', '2020-01-02 03:04:05 UTC', '$.collected_by', 'this very version'
);
update mysql.column_stats set histogram=json_replace(histogram, '$.collected_
by', replace(json_value(histogram, '$.collected_by'), @@version, 'version')
);
set global innodb_stats_persistent= @save_innodb_stats_persistent;
alter table mysql.time_zone_name ORDER BY Name;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(Host 'localhost');
...
...
@@ -95,7 +96,7 @@ USE mysql;
LOCK TABLES `column_stats` WRITE;
/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
REPLACE INTO `column_stats` VALUES
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
0-01-02 03:04:05 UTC\", \"collected_by\": \"this very
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
2-01-07 07:07:00\", \"collected_by\": \"
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
UNLOCK TABLES;
...
...
@@ -709,7 +710,7 @@ USE mysql;
LOCK TABLES `column_stats` WRITE;
/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
REPLACE INTO `column_stats` VALUES
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
0-01-02 03:04:05 UTC\", \"collected_by\": \"this very
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
2-01-07 07:07:00\", \"collected_by\": \"
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
UNLOCK TABLES;
...
...
@@ -1300,7 +1301,7 @@ USE mysql;
LOCK TABLES `column_stats` WRITE;
/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
INSERT IGNORE INTO `column_stats` VALUES
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
0-01-02 03:04:05 UTC\", \"collected_by\": \"this very
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"202
2-01-07 07:07:00\", \"collected_by\": \"
version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
UNLOCK TABLES;
...
...
mysql-test/main/mysqldump-system.test
View file @
307b2991
...
...
@@ -43,14 +43,15 @@ create table mysql.tz like mysql.time_zone_transition;
alter
table
mysql
.
tz
engine
=
innodb
;
insert
into
mysql
.
tz
select
*
from
mysql
.
time_zone_transition
;
set
global
innodb_stats_persistent
=
1
;
set
time_zone
=
"+03:00"
;
SET
TIMESTAMP
=
UNIX_TIMESTAMP
(
'2022-01-07 07:07:00'
);
ANALYZE
TABLE
mysql
.
tz
PERSISTENT
FOR
ALL
;
# for predictable output in tests
delete
from
mysql
.
index_stats
where
prefix_arity
!=
1
;
delete
from
mysql
.
column_stats
where
column_name
!=
'Time_zone_id'
;
set
time_zone
=
"+03:00"
;
update
mysql
.
innodb_index_stats
set
last_update
=
"2020-01-01"
where
database_name
=
"mysql"
and
table_name
=
"tz"
;
update
mysql
.
innodb_table_stats
set
last_update
=
"2020-01-01"
where
database_name
=
"mysql"
and
table_name
=
"tz"
;
update
mysql
.
column_stats
set
histogram
=
json_replace
(
histogram
,
'$.collected_
at'
,
'2020-01-02 03:04:05 UTC'
,
'$.collected_by'
,
'this very version'
);
update
mysql
.
column_stats
set
histogram
=
json_replace
(
histogram
,
'$.collected_
by'
,
replace
(
json_value
(
histogram
,
'$.collected_by'
),
@@
version
,
'version'
)
);
set
global
innodb_stats_persistent
=
@
save_innodb_stats_persistent
;
alter
table
mysql
.
time_zone_name
ORDER
BY
Name
;
...
...
sql/opt_histogram_json.cc
View file @
307b2991
...
...
@@ -178,22 +178,13 @@ class Histogram_json_builder : public Histogram_builder
void
append_histogram_params
()
{
char
buf
[
128
];
String
str
(
buf
,
sizeof
(
buf
),
system_charset_info
);
THD
*
thd
=
current_thd
;
timeval
tv
=
{
thd
->
query_start
(),
0
};
// we do not need microseconds
time_t
cur_time_t
=
my_time
(
0
);
struct
tm
curtime
;
localtime_r
(
&
cur_time_t
,
&
curtime
);
my_snprintf
(
buf
,
sizeof
(
buf
),
"%d-%02d-%02d %2d:%02d:%02d %s"
,
curtime
.
tm_year
+
1900
,
curtime
.
tm_mon
+
1
,
curtime
.
tm_mday
,
curtime
.
tm_hour
,
curtime
.
tm_min
,
curtime
.
tm_sec
,
system_time_zone
);
Timestamp
(
tv
).
to_datetime
(
thd
).
to_string
(
&
str
,
0
);
writer
.
add_member
(
"target_histogram_size"
).
add_ull
(
hist_width
);
writer
.
add_member
(
"collected_at"
).
add_str
(
buf
);
writer
.
add_member
(
"collected_at"
).
add_str
(
str
.
ptr
()
);
writer
.
add_member
(
"collected_by"
).
add_str
(
server_version
);
}
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment