Skip to content

Commit

Permalink
types: fix SQLTypeName for VoidFamily
Browse files Browse the repository at this point in the history
Release note (bug fix): Fixed a bug where format_type on the void type
results in an error.
  • Loading branch information
otan committed May 16, 2022
1 parent 2afa29c commit c83bb59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/builtin_function
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,7 @@ VALUES (format_type('anyelement'::regtype, -1)),
(format_type('unknown'::regtype, -1)),
(format_type('varbit'::regtype, -1)),
(format_type('varchar'::regtype, -1)),
(format_type('void'::regtype, -1)),
(format_type('int[]'::regtype, -1)),
(format_type('int2[]'::regtype, -1)),
(format_type('string[]'::regtype, -1)),
Expand Down Expand Up @@ -2102,6 +2103,7 @@ uuid
unknown
bit varying
character varying
void
bigint[]
smallint[]
text[]
Expand Down Expand Up @@ -2155,6 +2157,10 @@ SELECT format_type(oid, -1) FROM pg_type WHERE typname='_text' LIMIT 1
----
text[]

# Ensure each type can be formatted.
statement ok
SELECT format_type(oid, NULL) FROM pg_type

query T
SELECT pg_catalog.pg_get_userbyid((SELECT oid FROM pg_roles WHERE rolname='root'))
----
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,8 @@ func (t *T) SQLStandardNameWithTypmod(haveTypmod bool, typmod int) string {
return "unknown"
case UuidFamily:
return "uuid"
case VoidFamily:
return "void"
case EnumFamily:
return t.TypeMeta.Name.Basename()
default:
Expand Down

0 comments on commit c83bb59

Please sign in to comment.