Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSGO-2 marshalBigInt return 8 bytes slice in all cases except for big.Int, which returns a variable length slice #1740

Open
fesiqueira opened this issue Mar 1, 2024 · 1 comment · May be fixed by #1823

Comments

@fesiqueira
Copy link

fesiqueira commented Mar 1, 2024

What version of Cassandra are you using?

3.11.11

What version of Gocql are you using?

v1.6.0

What version of Go are you using?

1.21.6

What did you do?

Marshaled a big.Int variable. A example can be found here: https://go.dev/play/p/xShpJBbX2f2

What did you expect to see?

I expected the query to work

What did you see instead?

A Cassandra error message: Expected 8 or 0 byte long (7).


What happens is that when Marshaling to bigint, for all other types the marshalBigInt internal function will return a slice with length 8, but for big.Int it returns a variable length slice, which can sometimes be 7, 14, ..., depending of the underlying value of the big.Int.

I'd like to know if it's known and if it's a bug. Per math/big documentation, to get a fixed length slice the big.Int.FillBytes should be used instead.

@OleksiienkoMykyta
Copy link
Contributor

Hello, Felipe!
This issue is caused by different bigint types of implementations in Cassandra and in the driver. Cassandra has a limitation in eight-byte for bigint, however, in gocql it's implemented as an arbitrary-precision type.
It's already fixed, thank you for issuing it.
Have a great day!

@joao-r-reis joao-r-reis changed the title marshalBigInt return 8 bytes slice in all cases except for big.Int, which returns a variable length slice CASSGO-2 marshalBigInt return 8 bytes slice in all cases except for big.Int, which returns a variable length slice Oct 30, 2024
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 a pull request may close this issue.

2 participants