From e0ab52d4219edf39d4721c9f04ac46b304c9ad2b Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Sun, 5 Jul 2026 14:31:07 +0000 Subject: [PATCH] sql: reject array-of-list/map from polymorphic array functions array_remove (and other polymorphic array functions) could resolve their result to `array of list`/`array of map`, which has no pg type OID and crashed the pgwire connection when the row description was encoded. Reject it at plan time, like the ARRAY[] constructor and array_fill already do. Closes SQL-458 Co-Authored-By: Claude Opus 4.8 (1M context) --- src/sql/src/func.rs | 11 +++++++++++ test/sqllogictest/arrays.slt | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/sql/src/func.rs b/src/sql/src/func.rs index b7f80797264f8..b0061a2edb6ca 100644 --- a/src/sql/src/func.rs +++ b/src/sql/src/func.rs @@ -1627,6 +1627,17 @@ fn coerce_args_to_types( // polymorphic type. PlanError::UnsolvablePolymorphicFunctionInput })?; + if let SqlScalarType::Array(elem) = &target { + if matches!( + **elem, + SqlScalarType::List { .. } | SqlScalarType::Map { .. } + ) { + bail_unsupported!(format!( + "{}[]", + ecx.humanize_sql_scalar_type(elem, false) + )); + } + } do_convert(cexpr, &target)? } }; diff --git a/test/sqllogictest/arrays.slt b/test/sqllogictest/arrays.slt index 04d323f77a576..f2b4ad8639234 100644 --- a/test/sqllogictest/arrays.slt +++ b/test/sqllogictest/arrays.slt @@ -585,6 +585,21 @@ SELECT array_remove(ARRAY[1,1,1], 1) query error removing elements from multidimensional arrays is not supported SELECT array_remove(ARRAY[[1]], 1) +query error integer list\[\] not yet supported +SELECT array_remove(NULL, LIST[1]) + +query error map\[text=>integer\]\[\] not yet supported +SELECT array_remove(NULL, '{a=>1}'::map[text=>int4]) + +statement ok +CREATE TABLE t0 (c3 int4 list) + +query error integer list\[\] not yet supported +SELECT array_remove('[2020-01-01,2021-01-01)', t0.c3) AS col0 FROM t0 + +statement ok +DROP TABLE t0 + # array_cat query T