Documentation
¶
Overview ¶
Package value decodes field values from unpacked records, using the field descriptors stored in RDB$FORMATS, and formats them for output.
Index ¶
- Constants
- func Alignment(dtype uint8) uint32
- func BytesPerChar(id int) int
- func CharsetByName(name string) (int, bool)
- func CharsetName(id int) string
- func Convert(v any, to Field) (any, error)
- func Decodable(id int) bool
- func Decode(rec []byte, f Field, opt Options) (any, error)
- func DecodeBytes(b []byte, f Field, opt Options) (any, error)
- func IsNull(rec []byte, f Field) bool
- type BigDecimal
- type BlobRef
- type Date
- type DecFloat
- type Decimal
- type Field
- type Octets
- type Options
- type Text
- type Time
- type TimeTZ
- type Timestamp
- type TimestampTZ
Constants ¶
const ( TypeText = 1 TypeVarying = 3 TypeShort = 8 TypeLong = 9 TypeQuad = 10 TypeReal = 11 TypeDouble = 12 TypeDate = 14 TypeTime = 15 TypeTimestamp = 16 TypeBlob = 17 TypeArray = 18 TypeInt64 = 19 TypeBoolean = 21 TypeDec64 = 22 TypeDec128 = 23 TypeInt128 = 24 TypeTimeTZ = 25 TypeTimestampTZ = 26 )
Physical data types (dsc_dtype).
const DescriptorSize = 12
DescriptorSize is the on-disk size of a Field.
Variables ¶
This section is empty.
Functions ¶
func Alignment ¶
Alignment is the engine's alignment of a field of type dtype in a record: fields are laid out in field id order after the null bitmap, each at the next multiple of its alignment. Checked against every record format in the corpus.
func BytesPerChar ¶
BytesPerChar returns the maximum bytes per character of a character set.
func CharsetByName ¶
CharsetByName finds a character set id by its Firebird name, ignoring case.
func CharsetName ¶
CharsetName returns the Firebird name of a character set id.
func Convert ¶
Convert converts a value read with an older format of a column to the column's current type, as the engine does when it reads old records. Only conversions that ALTER COLUMN TYPE allows between the types fbrescue decodes are supported.
func Decodable ¶
Decodable reports whether text in this character set is converted to UTF-8 (true) or may be passed through as raw bytes (false).
func Decode ¶
Decode returns the value of field f in record rec: nil for NULL, or one of Decimal, BigDecimal, DecFloat, float32, float64, Date, Time, Timestamp, TimeTZ, TimestampTZ, Text, Octets, bool, BlobRef.
func DecodeBytes ¶
DecodeBytes decodes a value stored in b (exactly f.Length bytes).
Types ¶
type BigDecimal ¶
BigDecimal is an INT128 or NUMERIC/DECIMAL(19..38): Int * 10^Scale.
func (BigDecimal) IsMin ¶
func (d BigDecimal) IsMin() bool
IsMin reports the most negative INT128, whose literal does not parse.
func (BigDecimal) String ¶
func (d BigDecimal) String() string
String formats with exactly -Scale fraction digits.
type BlobRef ¶
type BlobRef struct {
Relation uint16
Number uint64 // record number of the blob header
SubType int16 // 1 text, 0 binary, others user-defined
Charset int // text blobs
}
BlobRef is a blob id field; the blob is read separately.
type DecFloat ¶
type DecFloat string
DecFloat is a DECFLOAT value, formatted as decNumber's to-scientific-string does (and as Firebird shows it).
type Field ¶
type Field struct {
ID int // position in the format; also the bit in the null bitmap
DType uint8
Scale int8
Length uint16
SubType int16 // text: character set (low byte) and collation; numbers: 1 NUMERIC, 2 DECIMAL
Flags uint16
Offset uint32 // 0: not stored (computed field)
}
Field is one entry of a record format (Ods::Descriptor): 12 bytes on disk.
func (Field) CharLength ¶
CharLength is the declared length in characters of a text field.
func (Field) SQLType ¶
SQLType returns the column type for CREATE TABLE. Precision of NUMERIC and DECIMAL is not stored in the format; the maximum for the storage size is used, so every stored value fits.
type Options ¶
type Options struct {
// NoneCharset decodes CHARACTER SET NONE text with this character set
// id instead of passing the bytes through. 0 means pass through.
NoneCharset int
}
Options controls decoding.
type Text ¶
Text is a decoded string. Raw is set when the bytes could not be decoded to UTF-8 (unknown character set, or NONE with non-UTF-8 bytes); the string then holds the original bytes.
type TimestampTZ ¶
TimestampTZ is a TIMESTAMP WITH TIME ZONE: UTC timestamp and a zone.
func (TimestampTZ) Format ¶
func (t TimestampTZ) Format() (string, error)
Format shows the local timestamp and the zone, as SELECT does.