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
4842a563
Commit
4842a563
authored
Jan 14, 2022
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSON_HB histogram: represent values of BIT() columns in hex always
parent
dae20dde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
16 deletions
+81
-16
mysql-test/main/statistics_json.result
mysql-test/main/statistics_json.result
+49
-11
mysql-test/main/statistics_json.test
mysql-test/main/statistics_json.test
+15
-0
sql/opt_histogram_json.cc
sql/opt_histogram_json.cc
+17
-5
No files found.
mysql-test/main/statistics_json.result
View file @
4842a563
...
...
@@ -374,23 +374,23 @@ test t1 f 1 5 0.2000 6.4000 4 JSON_HB {
"collected_by": "REPLACED",
"histogram_hb": [
{
"start
": "\u00
01",
"start
_hex": "
01",
"size": 0.28125,
"ndv": 2
},
{
"start
": "\u00
02",
"start
_hex": "
02",
"size": 0.28125,
"ndv": 2
},
{
"start
": "\u00
04",
"start
_hex": "
04",
"size": 0.3125,
"ndv": 1
},
{
"start
": "\u00
05",
"end
": "\u00
05",
"start
_hex": "
05",
"end
_hex": "
05",
"size": 0.125,
"ndv": 1
}
...
...
@@ -586,28 +586,28 @@ test t1 f 1 5 0.2000 6.4000 5 JSON_HB {
"collected_by": "REPLACED",
"histogram_hb": [
{
"start
": "\u00
01",
"start
_hex": "
01",
"size": 0.125,
"ndv": 1
},
{
"start
": "\u00
02",
"start
_hex": "
02",
"size": 0.25,
"ndv": 1
},
{
"start
": "\u00
03",
"start
_hex": "
03",
"size": 0.1875,
"ndv": 1
},
{
"start
": "\u00
04",
"start
_hex": "
04",
"size": 0.3125,
"ndv": 1
},
{
"start
": "\u00
05",
"end
": "\u00
05",
"start
_hex": "
05",
"end
_hex": "
05",
"size": 0.125,
"ndv": 1
}
...
...
@@ -8284,3 +8284,41 @@ analyze select f from t1 where f in (77, 1, 144, 73, 14, 12);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 20 20.00 10.00 10.00 Using where
drop table t1;
#
# Test that histograms over BIT fields use hex
#
create table t1 (a BIT(64));
insert into t1 values
(x'01'),(x'10'),(x'BE562B1A99001918');
set histogram_type= JSON_HB;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select histogram
from mysql.column_stats where table_name='t1' and db_name=database();
histogram
{
"target_histogram_size": 254,
"collected_at": "REPLACED",
"collected_by": "REPLACED",
"histogram_hb": [
{
"start_hex": "0000000000000001",
"size": 0.333333333,
"ndv": 1
},
{
"start_hex": "0000000000000010",
"size": 0.333333333,
"ndv": 1
},
{
"start_hex": "BE562B1A99001918",
"end_hex": "BE562B1A99001918",
"size": 0.333333333,
"ndv": 1
}
]
}
drop table t1;
mysql-test/main/statistics_json.test
View file @
4842a563
...
...
@@ -445,3 +445,18 @@ analyze table t1 persistent for all;
analyze
select
f
from
t1
where
f
in
(
77
,
1
,
144
,
73
,
14
,
12
);
drop
table
t1
;
--
echo
#
--
echo
# Test that histograms over BIT fields use hex
--
echo
#
create
table
t1
(
a
BIT
(
64
));
insert
into
t1
values
(
x
'01'
),(
x
'10'
),(
x
'BE562B1A99001918'
);
set
histogram_type
=
JSON_HB
;
analyze
table
t1
persistent
for
all
;
--
source
include
/
json_hb_histogram
.
inc
select
histogram
from
mysql
.
column_stats
where
table_name
=
't1'
and
db_name
=
database
();
drop
table
t1
;
sql/opt_histogram_json.cc
View file @
4842a563
...
...
@@ -122,6 +122,12 @@ class Histogram_json_builder : public Histogram_builder
/* Number of the buckets already collected */
uint
n_buckets_collected
;
/*
TRUE means do not try to represent values as UTF-8 text in histogram
storage. Use start_hex/end_hex for all values.
*/
bool
force_binary
;
/* Data about the bucket we are filling now */
struct
CurBucket
{
...
...
@@ -135,6 +141,7 @@ class Histogram_json_builder : public Histogram_builder
/* Used to create the JSON representation of the histogram. */
Json_writer
writer
;
public:
Histogram_json_builder
(
Histogram_json_hb
*
hist
,
Field
*
col
,
uint
col_len
,
...
...
@@ -155,6 +162,7 @@ class Histogram_json_builder : public Histogram_builder
n_buckets_collected
=
0
;
bucket
.
ndv
=
0
;
bucket
.
size
=
0
;
force_binary
=
(
col
->
type
()
==
MYSQL_TYPE_BIT
);
writer
.
start_object
();
append_histogram_params
();
...
...
@@ -244,12 +252,16 @@ class Histogram_json_builder : public Histogram_builder
// Escape the value for JSON
StringBuffer
<
MAX_FIELD_WIDTH
>
escaped_val
;
int
rc
=
json_escape_to_string
(
str
,
&
escaped_val
)
;
if
(
!
rc
)
int
rc
=
JSON_ERROR_ILLEGAL_SYMBOL
;
if
(
!
force_binary
)
{
writer
.
add_member
(
is_start
?
"start"
:
"end"
);
writer
.
add_str
(
escaped_val
.
c_ptr_safe
());
return
false
;
rc
=
json_escape_to_string
(
str
,
&
escaped_val
);
if
(
!
rc
)
{
writer
.
add_member
(
is_start
?
"start"
:
"end"
);
writer
.
add_str
(
escaped_val
.
c_ptr_safe
());
return
false
;
}
}
if
(
rc
==
JSON_ERROR_ILLEGAL_SYMBOL
)
{
...
...
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