apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.19k stars 1.29k forks source link

fix: encodeTuple int32 panic #11339

Closed linehk closed 1 month ago

linehk commented 2 months ago

When using int32 type in tuple and Pack, error will occur:

panic: unencodable element at index 0 (1, type int32)

The following example can be reproduced:

package main

import (
    "github.com/apple/foundationdb/bindings/go/src/fdb"
    "github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
)

func main() {
    fdb.MustAPIVersion(730)
    var i int32 = 1
    tuple.Tuple{i}.Pack()
}

This is because encodeTuple does not handle int32.

In the Go language, int and int32 are not the same type.

Fixed by adding support for int32.

Code-Reviewer Section

The general pull request guidelines can be found here.

Please check each of the following things and check all boxes before accepting a PR.

For Release-Branches

If this PR is made against a release-branch, please also check the following:

foundationdb-ci commented 2 months ago

Result of foundationdb-pr-clang-ide on Linux CentOS 7

foundationdb-ci commented 2 months ago

Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x

foundationdb-ci commented 2 months ago

Result of foundationdb-pr on Linux CentOS 7

foundationdb-ci commented 2 months ago

Result of foundationdb-pr-cluster-tests on Linux CentOS 7

foundationdb-ci commented 2 months ago

Result of foundationdb-pr-macos on macOS Ventura 13.x

foundationdb-ci commented 2 months ago

Result of foundationdb-pr-clang on Linux CentOS 7

linehk commented 1 month ago

CI failed, is there anything I need to add?

@jzhou77 @johscheuer PTAL.

linehk commented 1 month ago

OK, thanks for the explanation. I will close this PR.