-
I am calling a function with one deep nested composite type using pgx.
Does it mean FlatArray pointers are not supported? Why is this error thrown? Exception: panic({0x1661120?, 0xc000703dd0?})
/usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/jackc/pgx/v5/pgtype.(*FlatArray[...]).IndexType()
<autogenerated>:1 +0x85
github.com/jackc/pgx/v5/pgtype.(*ArrayCodec).PlanEncode(0xc00028e010, 0xc00015c310, 0x1cabe, 0x1, {0x16c4b60?, 0x0?})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/array_codec.go:68 +0x57
github.com/jackc/pgx/v5/pgtype.(*Map).planEncode(0xc00015c310, 0x1cabe, 0x1, {0x16c4b60?, 0x0})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1217 +0x156
github.com/jackc/pgx/v5/pgtype.(*Map).PlanEncode(0xc00015c310, 0x16c4aa0?, 0x1, {0x16c4b60, 0x0})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1185 +0x16f
github.com/jackc/pgx/v5/pgtype.(*CompositeBinaryBuilder).AppendValue(0xc0000de790, 0x1cabe, {0x16c4b60?, 0x0})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/composite.go:487 +0x1c6
github.com/jackc/pgx/v5/pgtype.(*encodePlanCompositeCodecCompositeIndexGetterToBinary).Encode(0xc000703b30, {0x16d4660?, 0xc000329560}, {0xc000142980, 0x47, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/composite.go:86 +0x193
github.com/jackc/pgx/v5/pgtype.(*wrapAnyStructEncodePlan).Encode(0xc000703b20, {0x170a9a0, 0xc000169130}, {0xc000142980, 0x47, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1749 +0x122
github.com/jackc/pgx/v5/pgtype.(*derefPointerEncodePlan).Encode(0xc000703b10, {0x16135a0?, 0xc0004aa140?}, {0xc000142980, 0x47, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1327 +0x136
github.com/jackc/pgx/v5/pgtype.(*CompositeBinaryBuilder).AppendValue(0xc0000de9c0, 0x1cadd, {0x16135a0?, 0xc0004aa140})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/composite.go:496 +0x367
github.com/jackc/pgx/v5/pgtype.(*encodePlanCompositeCodecCompositeIndexGetterToBinary).Encode(0xc000703b00, {0x16d4660?, 0xc000329440}, {0xc000142980, 0x0, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/composite.go:86 +0x193
github.com/jackc/pgx/v5/pgtype.(*wrapAnyStructEncodePlan).Encode(0xc000703af0, {0x16bf6a0, 0xc000329410}, {0xc000142980, 0x0, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1749 +0x122
github.com/jackc/pgx/v5/pgtype.(*derefPointerEncodePlan).Encode(0xc000703ae0, {0x1613620?, 0xc000202f30?}, {0xc000142980, 0x0, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1327 +0x136
github.com/jackc/pgx/v5/pgtype.(*derefPointerEncodePlan).Encode(0xc000703ac0, {0x161a680?, 0xc0004b61b8?}, {0xc000142980, 0x0, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1327 +0x136
github.com/jackc/pgx/v5/pgtype.(*Map).Encode(0x161a680?, 0x4b61b8?, 0xc0?, {0x161a680, 0xc0004b61b8}, {0xc000142980, 0x0, 0x80})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgtype/pgtype.go:1921 +0x83
github.com/jackc/pgx/v5.(*ExtendedQueryBuilder).encodeExtendedParamValue(0xc000239080, 0xc00031cfe0?, 0x3292c0?, 0xc0?, {0x161a680, 0xc0004b61b8})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/extended_query_builder.go:126 +0xca
github.com/jackc/pgx/v5.(*ExtendedQueryBuilder).appendParam(0xc000239080, 0xc0003a0540?, 0x1cae0?, 0x1, {0x161a680?, 0xc0004b61b8?})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/extended_query_builder.go:76 +0x16b
github.com/jackc/pgx/v5.(*ExtendedQueryBuilder).appendParam(0xc000239080, 0xc00015c310, 0xded70?, 0xc0?, {0x161a680?, 0xc0004b61b8})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/extended_query_builder.go:56 +0xf2
github.com/jackc/pgx/v5.(*ExtendedQueryBuilder).Build(0xc000239080, 0xc00015c310, 0xc000168050, {0xc000036390?, 0x1, 0x1})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/extended_query_builder.go:37 +0x3a5
github.com/jackc/pgx/v5.(*Conn).execPrepared(0xc000238fc0, {0x183c670, 0xc000329230}, 0xc000168050, {0xc000036390?, 0x17663e8?, 0x28?})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/conn.go:562 +0x5f
github.com/jackc/pgx/v5.(*Conn).exec(0xc000238fc0, {0x183c670, 0xc000329230}, {0x17663e8, 0x28}, {0xc000036390?, 0xc000036390?, 0x1?})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/conn.go:505 +0x36a
github.com/jackc/pgx/v5.(*Conn).Exec(0xc000238fc0, {0x183c590?, 0x1d3b940?}, {0x17663e8, 0x28}, {0xc000036390, 0x1, 0x1})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/conn.go:448 +0x12f
github.com/jackc/pgx/v5/pgxpool.(*Conn).Exec(0xc000123680?, {0x183c590?, 0x1d3b940?}, {0x17663e8?, 0x1?}, {0xc000036390?, 0x1f205b8?, 0x10?})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgxpool/conn.go:83 +0x3c
github.com/jackc/pgx/v5/pgxpool.(*Pool).Exec(0xf148c48518a66667?, {0x183c590, 0x1d3b940}, {0x17663e8, 0x28}, {0xc000036390, 0x1, 0x1})
/Users/czer/go/pkg/mod/github.com/jackc/pgx/v5@v5.5.1/pgxpool/pool.go:589 +0xff The code from github.com/jackc/pgx/v5@v5.5.1/pgtype/array_codec.go:68: func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
arrayValuer, ok := value.(ArrayGetter)
if !ok {
return nil
}
elementType := arrayValuer.IndexType()
elementEncodePlan := m.PlanEncode(c.ElementType.OID, format, elementType)
if elementEncodePlan == nil {
if reflect.TypeOf(elementType) != nil {
return nil
}
}
switch format {
case BinaryFormatCode:
return &encodePlanArrayCodecBinary{ac: c, m: m, oid: oid}
case TextFormatCode:
return &encodePlanArrayCodecText{ac: c, m: m, oid: oid}
}
return nil
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I found the solution, I guess its because FlatArray is a slice and slices can be nil. |
Beta Was this translation helpful? Give feedback.
I think I found the solution, I guess its because FlatArray is a slice and slices can be nil.
I am still relatively new to Go.