Skip to content

Conversation

@p-lindberg
Copy link

This PR fixes the issue of marshalling size_t into appropriately sized integers, as described in this issue.

I went with the native nuint type, which should map 1-to-1 with size_t.

For the public API, I decided to cast the nuint returned by mdb_cursor_count to a long, as this seems more idiomatic and convenient for users when dealing with counts. However, this is a breaking change, and if avoiding it is preferred then we could cast to an int instead (but see below). I do think it makes sense to return a long though, as (I assume) the underlying implementation supports having more than 2^32 duplicate entries in a database, in which case an int would truncate the value.

For the transaction id, on the other hand, I decided to propagate the nuint to the public API. This seems like the safest option as it makes no assumptions on the possible values that can be returned by the C implementation. In principle one could probably cast safely to a long, but as an identifier it isn't meant to be used in arithmetic operations anyhow. Either way, I think this needs to be a breaking change, as an int transaction id is unsafe on platforms where the underlying implementation can return values greater than 2^32 - this can lead to id reuse, which could become a problem for long-running processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants