MCPcopy Create free account
hub / github.com/apecloud/myduckserver / NewPostgresType

Function NewPostgresType

pgtypes/pgtypes.go:391–409  ·  view source on GitHub ↗
(registry *pgtype.Map, oid uint32, modifier int32)

Source from the content-addressed store, hash-verified

389 Size int32
390 // Fallback indicates that the type is not supported by the pgtype package and is approximated to the `text` fallback type.
391 Fallback bool
392}
393
394func NewPostgresType(registry *pgtype.Map, oid uint32, modifier int32) (PostgresType, error) {
395 t, ok := registry.TypeForOID(oid)
396 if !ok {
397 return PostgresType{}, fmt.Errorf("unsupported type OID %d", oid)
398 }
399
400 var precision, scale int32
401 switch oid {
402 case pgtype.NumericOID, pgtype.NumericArrayOID:
403 precision, scale, _ = DecodePrecisionScale(int(modifier))
404 }
405
406 return PostgresType{
407 PG: t,
408 Precision: precision,
409 Scale: scale,
410 Size: PostgresTypeSize(oid),
411 }, nil
412}

Callers 1

processMessageMethod · 0.92

Calls 2

DecodePrecisionScaleFunction · 0.85
PostgresTypeSizeFunction · 0.85

Tested by

no test coverage detected