Skip to content

Commit 7bca78c

Browse files
committed
sql: return pgerror when creating ARRAY of type VOID
Arrays of type `VOID` are not supported. This commit replaces an internal error with a user error when trying to create them. Fixes #84224 Release note: None
1 parent 73d1df8 commit 7bca78c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/sql/logictest/testdata/logic_test/void

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,17 @@ query B
174174
WITH tab(x) AS (VALUES (NULL:::VOID)) SELECT x IS NOT NULL FROM tab
175175
----
176176
false
177+
178+
# Regression test for #84224. Arrays of type VOID are not allowed.
179+
statement error pgcode 42704 pq: array of type VOID is not supported
180+
SELECT ARRAY[''::VOID]
181+
182+
statement error pgcode 42704 pq: array of type VOID is not supported
183+
SELECT ARRAY[NULL::VOID]
184+
185+
statement ok
186+
CREATE TABLE t84224 (a STRING)
187+
188+
statement error pgcode 42704 pq: array of type VOID is not supported
189+
SELECT ARRAY[a::VOID] FROM t84224
190+

pkg/sql/sem/tree/type_check.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,9 @@ func (expr *Array) TypeCheck(
19431943
return nil, err
19441944
}
19451945

1946+
if typ.Family() == types.VoidFamily {
1947+
return nil, pgerror.Newf(pgcode.UndefinedObject, "array of type VOID is not supported")
1948+
}
19461949
expr.typ = types.MakeArray(typ)
19471950
for i := range typedSubExprs {
19481951
expr.Exprs[i] = typedSubExprs[i]

0 commit comments

Comments
 (0)