Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/sem/tree,sql/coltypes: remove PGDisplayName #28944

Merged
merged 1 commit into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/sql/coltypes/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
package coltypes

import (
"strings"

"github.com/lib/pq/oid"

"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/sem/types"
)
Expand Down Expand Up @@ -149,8 +153,8 @@ var typNameLiterals map[string]T

func init() {
typNameLiterals = make(map[string]T)
for _, t := range types.OidToType {
name := types.PGDisplayName(t)
for o, t := range types.OidToType {
name := strings.ToLower(oid.TypeName[o])
if _, ok := typNameLiterals[name]; !ok {
colTyp, err := DatumTypeToColumnType(t)
if err != nil {
Expand Down
64 changes: 0 additions & 64 deletions pkg/sql/sem/types/oid.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,62 +119,6 @@ var OidToType = map[oid.Oid]T{
oid.T_record: FamTuple,
}

// AliasedOidToName maps Postgres object IDs to type names for those OIDs that map to
// Cockroach types that have more than one associated OID, like Int. The name
// for these OIDs will override the type name of the corresponding type when
// looking up the display name for an OID.
var aliasedOidToName = map[oid.Oid]string{
// TODO(justin): find a better solution to this than mapping every array type.
oid.T_anyarray: "anyarray",
oid.T_bit: "bit",
oid.T__bit: "_bit",
oid.T_bpchar: "bpchar",
oid.T__bpchar: "_bpchar",
oid.T_bool: "bool",
oid.T__bool: "_bool",
oid.T_bytea: "bytea",
oid.T__bytea: "_bytea",
oid.T_char: "char",
oid.T__char: "_char",
oid.T_date: "date",
oid.T__date: "_date",
oid.T_float4: "float4",
oid.T__float4: "_float4",
oid.T_float8: "float8",
oid.T__float8: "_float8",
oid.T_inet: "inet",
oid.T__inet: "_inet",
oid.T_int2: "int2",
oid.T__int2: "_int2",
oid.T_int4: "int4",
oid.T__int4: "_int4",
oid.T_int8: "int8",
oid.T__int8: "_int8",
oid.T_interval: "interval",
oid.T__interval: "_interval",
oid.T_name: "name",
oid.T__name: "_name",
oid.T_numeric: "numeric",
oid.T__numeric: "_numeric",
oid.T_oid: "oid",
oid.T__oid: "_oid",
oid.T_text: "text",
oid.T__text: "_text",
oid.T_time: "time",
oid.T__time: "_time",
oid.T_timestamp: "timestamp",
oid.T__timestamp: "_timestamp",
oid.T_timestamptz: "timestamptz",
oid.T__timestamptz: "_timestamptz",
oid.T_uuid: "uuid",
oid.T__uuid: "_uuid",
oid.T_varchar: "varchar",
oid.T__varchar: "_varchar",
oid.T_oidvector: "oidvector",
oid.T_record: "record",
oid.T_int2vector: "int2vector",
}

// oidToArrayOid maps scalar type Oids to their corresponding array type Oid.
var oidToArrayOid = map[oid.Oid]oid.Oid{
oid.T_anyelement: oid.T_anyarray,
Expand Down Expand Up @@ -202,14 +146,6 @@ var oidToArrayOid = map[oid.Oid]oid.Oid{
oid.T_uuid: oid.T__uuid,
}

// PGDisplayName returns the Postgres display name for a given type.
func PGDisplayName(typ T) string {
if typname, ok := aliasedOidToName[typ.Oid()]; ok {
return typname
}
return typ.String()
}

// TOid represents an alias to the Int type with a different Postgres OID.
type TOid struct {
oidType oid.Oid
Expand Down