File: native_func_format_time.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (215 lines) | stat: -rw-r--r-- 5,011 bytes parent folder | download
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#
# Tests for the Performance Schema native function format_pico_time()
#

SELECT format_pico_time(NULL);
format_pico_time(NULL)
NULL

SELECT format_pico_time(0);
format_pico_time(0)
  0 ps

SELECT format_pico_time(1);
format_pico_time(1)
  1 ps

SELECT format_pico_time(999);
format_pico_time(999)
999 ps

SELECT format_pico_time(1000);
format_pico_time(1000)
1.00 ns

SELECT format_pico_time(1001);
format_pico_time(1001)
1.00 ns

SELECT format_pico_time(999999);
format_pico_time(999999)
1000.00 ns

SELECT format_pico_time(1000000);
format_pico_time(1000000)
1.00 us

SELECT format_pico_time(1000001);
format_pico_time(1000001)
1.00 us

SELECT format_pico_time(1010000);
format_pico_time(1010000)
1.01 us

SELECT format_pico_time(987654321);
format_pico_time(987654321)
987.65 us

SELECT format_pico_time(1000000000);
format_pico_time(1000000000)
1.00 ms

SELECT format_pico_time(999876000000);
format_pico_time(999876000000)
999.88 ms

SELECT format_pico_time(999999999999);
format_pico_time(999999999999)
1000.00 ms

SELECT format_pico_time(1000000000000);
format_pico_time(1000000000000)
1.00 s

SELECT format_pico_time(59000000000000);
format_pico_time(59000000000000)
59.00 s

SELECT format_pico_time(60000000000000);
format_pico_time(60000000000000)
1.00 min

SELECT format_pico_time(3549000000000000);
format_pico_time(3549000000000000)
59.15 min

SELECT format_pico_time(3599000000000000);
format_pico_time(3599000000000000)
59.98 min

SELECT format_pico_time(3600000000000000);
format_pico_time(3600000000000000)
1.00 h

SELECT format_pico_time(power(2, 63));
format_pico_time(power(2, 63))
106.75 d

SELECT format_pico_time((power(2, 63) - 1) * 2 + 1);
format_pico_time((power(2, 63) - 1) * 2 + 1)
213.50 d

SELECT format_pico_time(36000000.495523);
format_pico_time(36000000.495523)
36.00 us

SELECT format_pico_time(1000 * pow(10,12) * 86400);
format_pico_time(1000 * pow(10,12) * 86400)
1000.00 d

SELECT format_pico_time(86400000000000000000);
format_pico_time(86400000000000000000)
1000.00 d

SELECT format_pico_time(86400000000000000000+5000);
format_pico_time(86400000000000000000+5000)
1000.00 d

## Negative values are ok
SELECT format_pico_time(1010000 * -1);
format_pico_time(1010000 * -1)
-1.01 us

## Force exponent
SELECT format_pico_time(8650000000000000000099);
format_pico_time(8650000000000000000099)
1.00e+05 d

SELECT format_pico_time(-8650000000000000000099);
format_pico_time(-8650000000000000000099)
-1.00e+05 d

SELECT format_pico_time(8640000000000000000099 * 2);
format_pico_time(8640000000000000000099 * 2)
2.00e+05 d


## Text input
SELECT format_pico_time("foo");
format_pico_time("foo")
  0 ps
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: 'foo'

SELECT format_pico_time("");
format_pico_time("")
  0 ps

SELECT format_pico_time("118059162071741143500099");
format_pico_time("118059162071741143500099")
1.37e+06 d

SELECT format_pico_time("-118059162071741143500099");
format_pico_time("-118059162071741143500099")
-1.37e+06 d

## Recognizes up to first non-numeric
SELECT format_pico_time("40000 * 2000");
format_pico_time("40000 * 2000")
40.00 ns
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '40000 * 2000'

SELECT format_pico_time("40000 foo 2000");
format_pico_time("40000 foo 2000")
40.00 ns
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '40000 foo 2000'
## Aggregate functions
USE test;

CREATE TABLE timer_waits (id VARCHAR(10), wait BIGINT UNSIGNED DEFAULT NULL) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;

INSERT INTO timer_waits VALUES ('1 sec',          1000000000000);
INSERT INTO timer_waits VALUES ('1 min',         60000000000000);
INSERT INTO timer_waits VALUES ('1 hour',      3600000000000000);
INSERT INTO timer_waits VALUES ('1 day',      86400000000000000);
INSERT INTO timer_waits VALUES ('100 days', 8640000000000000000);

SELECT id, format_pico_time(wait), wait FROM timer_waits;
id	format_pico_time(wait)	wait
1 sec	1.00 s	1000000000000
1 min	1.00 min	60000000000000
1 hour	1.00 h	3600000000000000
1 day	1.00 d	86400000000000000
100 days	100.00 d	8640000000000000000

SELECT sum(wait), format_pico_time(sum(wait)) FROM timer_waits;
sum(wait)	format_pico_time(sum(wait))
8730061000000000000	101.04 d

SELECT avg(wait), format_pico_time(avg(wait)) FROM timer_waits;
avg(wait)	format_pico_time(avg(wait))
1746012200000000000.0000	20.21 d

SELECT min(wait), format_pico_time(min(wait)) FROM timer_waits;
min(wait)	format_pico_time(min(wait))
1000000000000	1.00 s

SELECT max(wait), format_pico_time(max(wait)) FROM timer_waits;
max(wait)	format_pico_time(max(wait))
8640000000000000000	100.00 d

DROP TABLE timer_waits;

## Handling of NULL (bug#30525561)
SELECT mytime,
FORMAT_PICO_TIME(mytime) AS PS_TIME,
sys.format_time(mytime) AS SYS_TIME
FROM (SELECT 1234 AS mytime
UNION ALL
SELECT 1234567890
UNION ALL
SELECT NULL
UNION ALL
SELECT 1234
UNION ALL
SELECT 1234567890
) t;
mytime	PS_TIME	SYS_TIME
1234	1.23 ns	1.23 ns
1234567890	1.23 ms	1.23 ms
NULL	NULL	NULL
1234	1.23 ns	1.23 ns
1234567890	1.23 ms	1.23 ms