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

Method PGName

pkg/sql/types/types.go:1713–1730  ·  view source on GitHub ↗

PGName returns the Postgres name for the type. This is sometimes different than the native CRDB name for it (i.e. the Name function). It is used when compatibility with PG is important. Examples of differences: Name() PGName() -------------------------- char bpchar "char" ch

()

Source from the content-addressed store, hash-verified

1711// bytes bytea
1712// int4[] _int4
1713func (t *T) PGName() string {
1714 name, ok := oidext.TypeName(t.Oid())
1715 if ok {
1716 return strings.ToLower(name)
1717 }
1718
1719 // For user defined types, return the basename.
1720 if t.UserDefined() {
1721 return t.TypeMeta.Name.Basename()
1722 }
1723
1724 // Postgres does not have an UNKNOWN[] type. However, CRDB does, so
1725 // manufacture a name for it.
1726 if t.Family() != ArrayFamily || t.ArrayContents().Family() != UnknownFamily {
1727 panic(errors.AssertionFailedf("unknown PG name for oid %d", t.Oid()))
1728 }
1729 return "_unknown"
1730}
1731
1732// SQLStandardName returns the type's name as it is specified in the SQL
1733// standard (or by Postgres for any non-standard types). This can be looked up

Callers 1

computeCastNameFunction · 0.80

Calls 6

OidMethod · 0.95
UserDefinedMethod · 0.95
FamilyMethod · 0.95
ArrayContentsMethod · 0.95
TypeNameFunction · 0.92
BasenameMethod · 0.80

Tested by

no test coverage detected