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

Method SQLStringForError

pkg/sql/types/types.go:2144–2178  ·  view source on GitHub ↗

SQLStringForError returns a version of SQLString that will preserve safe information during redaction. It is suitable for usage in error messages.

()

Source from the content-addressed store, hash-verified

2142// SQLStringForError returns a version of SQLString that will preserve safe
2143// information during redaction. It is suitable for usage in error messages.
2144func (t *T) SQLStringForError() redact.RedactableString {
2145 if t == nil {
2146 return "<nil>"
2147 }
2148 if t.UserDefined() {
2149 // Show the redacted SQLString output with an un-redacted prefix to indicate
2150 // that the type is user defined (and possibly enum or record).
2151 prefix := "TYPE"
2152 switch t.Family() {
2153 case EnumFamily:
2154 prefix = "ENUM"
2155 case TupleFamily:
2156 prefix = "RECORD"
2157 case ArrayFamily:
2158 prefix = "ARRAY"
2159 }
2160 return redact.Sprintf("USER DEFINED %s: %s", redact.Safe(prefix), t.SQLString())
2161 }
2162 switch t.Family() {
2163 case EnumFamily, TupleFamily, ArrayFamily:
2164 // These types can be or can contain user-defined types, but the SQLString
2165 // is safe when they are not user-defined. We filtered out the user-defined
2166 // case above.
2167 return redact.Sprint(redact.Safe(t.SQLString()))
2168 case BoolFamily, IntFamily, FloatFamily, DecimalFamily, DateFamily, TimestampFamily,
2169 IntervalFamily, StringFamily, BytesFamily, TimestampTZFamily, CollatedStringFamily, OidFamily,
2170 UnknownFamily, UuidFamily, INetFamily, TimeFamily, JsonFamily, TimeTZFamily, BitFamily,
2171 GeometryFamily, GeographyFamily, Box2DFamily, VoidFamily, EncodedKeyFamily, TSQueryFamily,
2172 TSVectorFamily, AnyFamily, PGLSNFamily, PGVectorFamily, RefCursorFamily:
2173 // These types do not contain other types, and do not require redaction.
2174 return redact.Sprint(redact.SafeString(t.SQLString()))
2175 }
2176 // Default to redaction for unhandled types.
2177 return redact.Sprint(t.SQLString())
2178}
2179
2180// FormatTypeName is an injected dependency from tree to properly format a
2181// type name. The logic for proper formatting lives in the tree package.

Callers 15

GetBoolFunction · 0.80
MaybeSetCustomOidMethod · 0.80
AppendMethod · 0.80
CompareMethod · 0.80
NewDIntVectorFromDArrayFunction · 0.80
NewDefaultDatumFunction · 0.80
DatumTypeSizeFunction · 0.80
ParseAndRequireStringFunction · 0.80
MemoizeComparisonExprOpFunction · 0.80
memoizeOpMethod · 0.80
cmpOpFixupsFunction · 0.80

Calls 3

UserDefinedMethod · 0.95
FamilyMethod · 0.95
SQLStringMethod · 0.95

Tested by

no test coverage detected