MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Name

Method Name

postgres/parser/types/types.go:1297–1375  ·  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

1295//
1296// TODO(andyk): Should these be changed to be the same as SQLStandardName?
1297func (t *T) Name() string {
1298 switch fam := t.Family(); fam {
1299 case AnyFamily:
1300 return "anyelement"
1301
1302 case ArrayFamily:
1303 switch t.Oid() {
1304 case oid.T_oidvector:
1305 return "oidvector"
1306 case oid.T_int2vector:
1307 return "int2vector"
1308 }
1309 return t.ArrayContents().Name() + "[]"
1310
1311 case BitFamily:
1312 if t.Oid() == oid.T_varbit {
1313 return "varbit"
1314 }
1315 return "bit"
1316
1317 case FloatFamily:
1318 switch t.Width() {
1319 case 64:
1320 return "float8"
1321 case 32:
1322 return "float4"
1323 default:
1324 panic(errors.AssertionFailedf("programming error: unknown float width: %d", t.Width()))
1325 }
1326
1327 case IntFamily:
1328 switch t.Width() {
1329 case 64:
1330 return "int8"
1331 case 32:
1332 return "int4"
1333 case 16:
1334 return "int2"
1335 default:
1336 panic(errors.AssertionFailedf("programming error: unknown int width: %d", t.Width()))
1337 }
1338
1339 case OidFamily:
1340 return t.SQLStandardName()
1341
1342 case StringFamily, CollatedStringFamily:
1343 switch t.Oid() {
1344 case oid.T_text:
1345 return "text"
1346 case oid.T_bpchar:
1347 return "char"
1348 case oid.T_char:
1349 // Yes, that's the name. The ways of PostgreSQL are inscrutable.
1350 return `"char"`
1351 case oid.T_varchar:
1352 return "varchar"
1353 case oid.T_name:
1354 return "name"

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