MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Format

Method Format

pkg/sql/sem/tree/datum.go:3056–3079  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

3054
3055// Format implements the NodeFormatter interface.
3056func (d *DTimestampTZ) Format(ctx *FmtCtx) {
3057 f := ctx.flags
3058 bareStrings := f.HasFlags(FmtFlags(lexbase.EncBareStrings))
3059 if !bareStrings {
3060 ctx.WriteByte('\'')
3061 }
3062 // By default, rely on the ctx location.
3063 loc := ctx.location
3064 // We sometimes set location correctly in DTimestampTZ.
3065 if loc == nil {
3066 loc = d.Location()
3067 }
3068 if f.HasFlags(fmtPgwireFormat) {
3069 // This assertion should be in place everywhere, but that's a
3070 // huge change for a different day.
3071 if loc == nil {
3072 panic(errors.AssertionFailedf("location on ctx for fmtPgwireFormat must be set for TimestampTZ types"))
3073 }
3074 }
3075 ctx.Write(PGWireFormatTimestamp(d.Time, loc, ctx.scratch[:0]))
3076 if !bareStrings {
3077 ctx.WriteByte('\'')
3078 }
3079}
3080
3081// Size implements the Datum interface.
3082func (d *DTimestampTZ) Size() uintptr {

Callers

nothing calls this directly

Calls 4

FmtFlagsTypeAlias · 0.85
PGWireFormatTimestampFunction · 0.85
WriteMethod · 0.80
HasFlagsMethod · 0.45

Tested by

no test coverage detected