@@ -3834,16 +3834,15 @@ concat_internal(const char *sepstr, int argidx,
3834
3834
return NULL ;
3835
3835
3836
3836
/*
3837
- * Non-null argument had better be an array
3838
- *
3839
- * Correct values are ensured by parser check, but this function
3840
- * can be called directly, bypassing the parser, so we should do
3841
- * some minimal check too - this form of call requires correctly set
3842
- * expr argtype in flinfo.
3837
+ * Non-null argument had better be an array. We assume that any call
3838
+ * context that could let get_fn_expr_variadic return true will have
3839
+ * checked that a VARIADIC-labeled parameter actually is an array. So
3840
+ * it should be okay to just Assert that it's an array rather than
3841
+ * doing a full-fledged error check.
3843
3842
*/
3844
- Assert (OidIsValid (get_fn_expr_argtype (fcinfo -> flinfo , argidx )));
3845
- Assert (OidIsValid (get_element_type (get_fn_expr_argtype (fcinfo -> flinfo , argidx ))));
3843
+ Assert (OidIsValid (get_base_element_type (get_fn_expr_argtype (fcinfo -> flinfo , argidx ))));
3846
3844
3845
+ /* OK, safe to fetch the array value */
3847
3846
arr = PG_GETARG_ARRAYTYPE_P (argidx );
3848
3847
3849
3848
/*
@@ -4063,16 +4062,15 @@ text_format(PG_FUNCTION_ARGS)
4063
4062
else
4064
4063
{
4065
4064
/*
4066
- * Non-null argument had better be an array
4067
- *
4068
- * Correct values are ensured by parser check, but this function
4069
- * can be called directly, bypassing the parser, so we should do
4070
- * some minimal check too - this form of call requires correctly set
4071
- * expr argtype in flinfo.
4065
+ * Non-null argument had better be an array. We assume that any
4066
+ * call context that could let get_fn_expr_variadic return true
4067
+ * will have checked that a VARIADIC-labeled parameter actually is
4068
+ * an array. So it should be okay to just Assert that it's an
4069
+ * array rather than doing a full-fledged error check.
4072
4070
*/
4073
- Assert (OidIsValid (get_fn_expr_argtype (fcinfo -> flinfo , 1 )));
4074
- Assert (OidIsValid (get_element_type (get_fn_expr_argtype (fcinfo -> flinfo , 1 ))));
4071
+ Assert (OidIsValid (get_base_element_type (get_fn_expr_argtype (fcinfo -> flinfo , 1 ))));
4075
4072
4073
+ /* OK, safe to fetch the array value */
4076
4074
arr = PG_GETARG_ARRAYTYPE_P (1 );
4077
4075
4078
4076
/* Get info about array element type */
0 commit comments