MCPcopy
hub / github.com/jackc/pgx / ColumnTypeLength

Method ColumnTypeLength

stdlib/sql.go:665–678  ·  view source on GitHub ↗

ColumnTypeLength returns the length of the column type if the column is a variable length type. If the column is not a variable length type ok should return false.

(index int)

Source from the content-addressed store, hash-verified

663// variable length type. If the column is not a variable length type ok
664// should return false.
665func (r *Rows) ColumnTypeLength(index int) (int64, bool) {
666 fd := r.rows.FieldDescriptions()[index]
667
668 switch fd.DataTypeOID {
669 case pgtype.TextOID, pgtype.ByteaOID:
670 return math.MaxInt64, true
671 case pgtype.VarcharOID, pgtype.BPCharOID:
672 return int64(fd.TypeModifier - varHeaderSize), true
673 case pgtype.VarbitOID:
674 return int64(fd.TypeModifier), true
675 default:
676 return 0, false
677 }
678}
679
680// ColumnTypePrecisionScale should return the precision and scale for decimal
681// types. If not applicable, ok should be false.

Callers

nothing calls this directly

Implementers 3

baseRowsrows.go
errRowspgxpool/rows.go
poolRowspgxpool/rows.go

Calls 1

FieldDescriptionsMethod · 0.65

Tested by

no test coverage detected