Skip to content

Consider using msgpack.encode instead tostring in hash function #207

@olegrok

Description

@olegrok

What's wrong with tostring:

tarantool> tostring(922337203685477580LL)
---
- 922337203685477580LL
...

tarantool> tostring(922337203685477580ULL)
---
- 922337203685477580ULL
...

Possible consequences:

tarantool> box.space.test:insert({922337203685477580LL})
---
- [922337203685477580]
...

tarantool> tostring(box.space.test:get({922337203685477580LL})[1])
---
- 922337203685477580ULL
...

Hashes calculated for "922337203685477580ULL" and "922337203685477580LL" are different. This could lead to some unexpected results for users. (I understand that tarantool internally uses msgpuck that stores any positive integer as unsigned)

Without breaking of backward compatibility I suggest to introduce new hash function that will be stable for such cases. Or at least document such behaviour.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions