@@ -53,79 +53,85 @@ SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM
53
53
10994579406847 | 10239 GB | -10239 GB
54
54
10994579406848 | 10 TB | -10 TB
55
55
11258449312612351 | 10239 TB | -10239 TB
56
- 11258449312612352 | 10240 TB | -10240 TB
56
+ 11258449312612352 | 10 PB | -10 PB
57
57
(10 rows)
58
58
59
59
SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM
60
60
(VALUES (10239::numeric), (10240::numeric),
61
61
(10485247::numeric), (10485248::numeric),
62
62
(10736893951::numeric), (10736893952::numeric),
63
63
(10994579406847::numeric), (10994579406848::numeric),
64
- (11258449312612351::numeric), (11258449312612352::numeric)) x(size);
65
- size | pg_size_pretty | pg_size_pretty
66
- -------------------+----------------+----------------
67
- 10239 | 10239 bytes | -10239 bytes
68
- 10240 | 10 kB | -10 kB
69
- 10485247 | 10239 kB | -10239 kB
70
- 10485248 | 10 MB | -10 MB
71
- 10736893951 | 10239 MB | -10239 MB
72
- 10736893952 | 10 GB | -10 GB
73
- 10994579406847 | 10239 GB | -10239 GB
74
- 10994579406848 | 10 TB | -10 TB
75
- 11258449312612351 | 10239 TB | -10239 TB
76
- 11258449312612352 | 10240 TB | -10240 TB
77
- (10 rows)
64
+ (11258449312612351::numeric), (11258449312612352::numeric),
65
+ (11528652096115048447::numeric), (11528652096115048448::numeric)) x(size);
66
+ size | pg_size_pretty | pg_size_pretty
67
+ ----------------------+----------------+----------------
68
+ 10239 | 10239 bytes | -10239 bytes
69
+ 10240 | 10 kB | -10 kB
70
+ 10485247 | 10239 kB | -10239 kB
71
+ 10485248 | 10 MB | -10 MB
72
+ 10736893951 | 10239 MB | -10239 MB
73
+ 10736893952 | 10 GB | -10 GB
74
+ 10994579406847 | 10239 GB | -10239 GB
75
+ 10994579406848 | 10 TB | -10 TB
76
+ 11258449312612351 | 10239 TB | -10239 TB
77
+ 11258449312612352 | 10 PB | -10 PB
78
+ 11528652096115048447 | 10239 PB | -10239 PB
79
+ 11528652096115048448 | 10240 PB | -10240 PB
80
+ (12 rows)
78
81
79
82
-- pg_size_bytes() tests
80
83
SELECT size, pg_size_bytes(size) FROM
81
84
(VALUES ('1'), ('123bytes'), ('1kB'), ('1MB'), (' 1 GB'), ('1.5 GB '),
82
- ('1TB'), ('3000 TB'), ('1e6 MB')) x(size);
83
- size | pg_size_bytes
84
- ----------+------------------
85
- 1 | 1
86
- 123bytes | 123
87
- 1kB | 1024
88
- 1MB | 1048576
89
- 1 GB | 1073741824
90
- 1.5 GB | 1610612736
91
- 1TB | 1099511627776
92
- 3000 TB | 3298534883328000
93
- 1e6 MB | 1048576000000
94
- (9 rows)
85
+ ('1TB'), ('3000 TB'), ('1e6 MB'), ('99 PB')) x(size);
86
+ size | pg_size_bytes
87
+ ----------+--------------------
88
+ 1 | 1
89
+ 123bytes | 123
90
+ 1kB | 1024
91
+ 1MB | 1048576
92
+ 1 GB | 1073741824
93
+ 1.5 GB | 1610612736
94
+ 1TB | 1099511627776
95
+ 3000 TB | 3298534883328000
96
+ 1e6 MB | 1048576000000
97
+ 99 PB | 111464090777419776
98
+ (10 rows)
95
99
96
100
-- case-insensitive units are supported
97
101
SELECT size, pg_size_bytes(size) FROM
98
102
(VALUES ('1'), ('123bYteS'), ('1kb'), ('1mb'), (' 1 Gb'), ('1.5 gB '),
99
- ('1tb'), ('3000 tb'), ('1e6 mb')) x(size);
100
- size | pg_size_bytes
101
- ----------+------------------
102
- 1 | 1
103
- 123bYteS | 123
104
- 1kb | 1024
105
- 1mb | 1048576
106
- 1 Gb | 1073741824
107
- 1.5 gB | 1610612736
108
- 1tb | 1099511627776
109
- 3000 tb | 3298534883328000
110
- 1e6 mb | 1048576000000
111
- (9 rows)
103
+ ('1tb'), ('3000 tb'), ('1e6 mb'), ('99 pb')) x(size);
104
+ size | pg_size_bytes
105
+ ----------+--------------------
106
+ 1 | 1
107
+ 123bYteS | 123
108
+ 1kb | 1024
109
+ 1mb | 1048576
110
+ 1 Gb | 1073741824
111
+ 1.5 gB | 1610612736
112
+ 1tb | 1099511627776
113
+ 3000 tb | 3298534883328000
114
+ 1e6 mb | 1048576000000
115
+ 99 pb | 111464090777419776
116
+ (10 rows)
112
117
113
118
-- negative numbers are supported
114
119
SELECT size, pg_size_bytes(size) FROM
115
120
(VALUES ('-1'), ('-123bytes'), ('-1kb'), ('-1mb'), (' -1 Gb'), ('-1.5 gB '),
116
- ('-1tb'), ('-3000 TB'), ('-10e-1 MB')) x(size);
117
- size | pg_size_bytes
118
- -----------+-------------------
119
- -1 | -1
120
- -123bytes | -123
121
- -1kb | -1024
122
- -1mb | -1048576
123
- -1 Gb | -1073741824
124
- -1.5 gB | -1610612736
125
- -1tb | -1099511627776
126
- -3000 TB | -3298534883328000
127
- -10e-1 MB | -1048576
128
- (9 rows)
121
+ ('-1tb'), ('-3000 TB'), ('-10e-1 MB'), ('-99 PB')) x(size);
122
+ size | pg_size_bytes
123
+ -----------+---------------------
124
+ -1 | -1
125
+ -123bytes | -123
126
+ -1kb | -1024
127
+ -1mb | -1048576
128
+ -1 Gb | -1073741824
129
+ -1.5 gB | -1610612736
130
+ -1tb | -1099511627776
131
+ -3000 TB | -3298534883328000
132
+ -10e-1 MB | -1048576
133
+ -99 PB | -111464090777419776
134
+ (10 rows)
129
135
130
136
-- different cases with allowed points
131
137
SELECT size, pg_size_bytes(size) FROM
@@ -147,15 +153,15 @@ SELECT size, pg_size_bytes(size) FROM
147
153
SELECT pg_size_bytes('1 AB');
148
154
ERROR: invalid size: "1 AB"
149
155
DETAIL: Invalid size unit: "AB".
150
- HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB ".
156
+ HINT: Valid units are "bytes", "kB", "MB", "GB", "TB", and "PB ".
151
157
SELECT pg_size_bytes('1 AB A');
152
158
ERROR: invalid size: "1 AB A"
153
159
DETAIL: Invalid size unit: "AB A".
154
- HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB ".
160
+ HINT: Valid units are "bytes", "kB", "MB", "GB", "TB", and "PB ".
155
161
SELECT pg_size_bytes('1 AB A ');
156
162
ERROR: invalid size: "1 AB A "
157
163
DETAIL: Invalid size unit: "AB A".
158
- HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB ".
164
+ HINT: Valid units are "bytes", "kB", "MB", "GB", "TB", and "PB ".
159
165
SELECT pg_size_bytes('9223372036854775807.9');
160
166
ERROR: bigint out of range
161
167
SELECT pg_size_bytes('1e100');
@@ -165,7 +171,7 @@ ERROR: value overflows numeric format
165
171
SELECT pg_size_bytes('1 byte'); -- the singular "byte" is not supported
166
172
ERROR: invalid size: "1 byte"
167
173
DETAIL: Invalid size unit: "byte".
168
- HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB ".
174
+ HINT: Valid units are "bytes", "kB", "MB", "GB", "TB", and "PB ".
169
175
SELECT pg_size_bytes('');
170
176
ERROR: invalid size: ""
171
177
SELECT pg_size_bytes('kb');
@@ -183,6 +189,6 @@ ERROR: invalid size: ".+912"
183
189
SELECT pg_size_bytes('+912+ kB');
184
190
ERROR: invalid size: "+912+ kB"
185
191
DETAIL: Invalid size unit: "+ kB".
186
- HINT: Valid units are "bytes", "kB", "MB", "GB", and "TB ".
192
+ HINT: Valid units are "bytes", "kB", "MB", "GB", "TB", and "PB ".
187
193
SELECT pg_size_bytes('++123 kB');
188
194
ERROR: invalid size: "++123 kB"
0 commit comments