Commit b866691
committed
msgpack: support decimals with negative scale
Current decimal external type parser do not expect negative scale in
decimal payload. Negative scale is a positive exponent. It seems that
the only way to obtain positive exponent is to use E-notation since
Tarantool library do not truncate trailing zeroes before decimal point:
```
tarantool> msgpack.encode(decimal.new('1e33')):hex()
---
- c70301d0df1c
...
tarantool> msgpack.encode(decimal.new('1000000000000000000000000000000000')):hex()
---
- c713010001000000000000000000000000000000000c
...
```
There are two different bugs in current implementation:
- we support only `positive fixint` scale and do not expect `int 8` [2],
- we do not expect negative scale so positive exponent will be ignored.
This patch fixes both of them. See also [3].
1. https://github.com/tarantool/tarantool/blob/ba749e820bf0638aa3f79f266848590f9713c1cf/src/lib/core/decimal.c#L432-L450
2. https://github.com/msgpack/msgpack/blob/master/spec.md
3. tarantool/go-tarantool#3141 parent 9c8945f commit b866691
File tree
3 files changed
+52
-3
lines changed- tarantool/msgpack_ext
- test/suites
3 files changed
+52
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
353 | 355 | | |
354 | 356 | | |
355 | 357 | | |
356 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| |||
362 | 369 | | |
363 | 370 | | |
364 | 371 | | |
365 | | - | |
| 372 | + | |
366 | 373 | | |
367 | 374 | | |
368 | 375 | | |
| |||
372 | 379 | | |
373 | 380 | | |
374 | 381 | | |
375 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
376 | 389 | | |
377 | 390 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
229 | 262 | | |
230 | 263 | | |
231 | 264 | | |
| |||
0 commit comments