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

Method Name

pkg/sql/types/types.go:1614–1701  ·  view source on GitHub ↗

Name returns a single word description of the type that describes it succinctly, but without all the details, such as width, locale, etc. The name is sometimes the same as the name returned by SQLStandardName, but is more CRDB friendly. TODO(andyk): Should these be changed to be the same as SQLStan

()

Source from the content-addressed store, hash-verified

1612//
1613// TODO(andyk): Should these be changed to be the same as SQLStandardName?
1614func (t *T) Name() string {
1615 switch fam := t.Family(); fam {
1616 case AnyFamily:
1617 switch t.Oid() {
1618 case oid.T_any:
1619 return "any"
1620 default:
1621 return "anyelement"
1622 }
1623
1624 case ArrayFamily:
1625 switch t.Oid() {
1626 case oid.T_oidvector:
1627 return "oidvector"
1628 case oid.T_int2vector:
1629 return "int2vector"
1630 case oid.T_anyarray:
1631 return "anyarray"
1632 }
1633 return t.ArrayContents().Name() + "[]"
1634
1635 case BitFamily:
1636 if t.Oid() == oid.T_varbit {
1637 return "varbit"
1638 }
1639 return "bit"
1640
1641 case FloatFamily:
1642 switch t.Width() {
1643 case 64:
1644 return "float"
1645 case 32:
1646 return "float4"
1647 default:
1648 panic(errors.AssertionFailedf("programming error: unknown float width: %d", t.Width()))
1649 }
1650
1651 case IntFamily:
1652 switch t.Width() {
1653 case 64:
1654 return "int"
1655 case 32:
1656 return "int4"
1657 case 16:
1658 return "int2"
1659 default:
1660 panic(errors.AssertionFailedf("programming error: unknown int width: %d", t.Width()))
1661 }
1662
1663 case OidFamily:
1664 return t.SQLStandardName()
1665
1666 case StringFamily, CollatedStringFamily:
1667 switch t.Oid() {
1668 case oid.T_text:
1669 return "string"
1670 case oid.T_bpchar:
1671 if t.Width() == 0 {

Callers 3

SQLStringMethod · 0.95
StringMethod · 0.95

Calls 7

FamilyMethod · 0.95
OidMethod · 0.95
ArrayContentsMethod · 0.95
WidthMethod · 0.95
SQLStandardNameMethod · 0.95
BasenameMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected