@@ -3820,7 +3820,6 @@ concat_internal(const char *sepstr, int argidx,
38203820 */
38213821 if (get_fn_expr_variadic (fcinfo -> flinfo ))
38223822 {
3823- Oid arr_typid ;
38243823 ArrayType * arr ;
38253824
38263825 /* Should have just the one argument */
@@ -3831,20 +3830,16 @@ concat_internal(const char *sepstr, int argidx,
38313830 return NULL ;
38323831
38333832 /*
3834- * Non-null argument had better be an array. The parser doesn't
3835- * enforce this for VARIADIC ANY functions (maybe it should?), so that
3836- * check uses ereport not just elog.
3833+ * Non-null argument had better be an array
3834+ *
3835+ * Correct values are ensured by parser check, but this function
3836+ * can be called directly, bypassing the parser, so we should do
3837+ * some minimal check too - this form of call requires correctly set
3838+ * expr argtype in flinfo.
38373839 */
3838- arr_typid = get_fn_expr_argtype (fcinfo -> flinfo , argidx );
3839- if (!OidIsValid (arr_typid ))
3840- elog (ERROR , "could not determine data type of concat() input" );
3841-
3842- if (!OidIsValid (get_element_type (arr_typid )))
3843- ereport (ERROR ,
3844- (errcode (ERRCODE_DATATYPE_MISMATCH ),
3845- errmsg ("VARIADIC argument must be an array" )));
3840+ Assert (OidIsValid (get_fn_expr_argtype (fcinfo -> flinfo , argidx )));
3841+ Assert (OidIsValid (get_element_type (get_fn_expr_argtype (fcinfo -> flinfo , argidx ))));
38463842
3847- /* OK, safe to fetch the array value */
38483843 arr = PG_GETARG_ARRAYTYPE_P (argidx );
38493844
38503845 /*
@@ -4049,7 +4044,6 @@ text_format(PG_FUNCTION_ARGS)
40494044 /* If argument is marked VARIADIC, expand array into elements */
40504045 if (get_fn_expr_variadic (fcinfo -> flinfo ))
40514046 {
4052- Oid arr_typid ;
40534047 ArrayType * arr ;
40544048 int16 elmlen ;
40554049 bool elmbyval ;
@@ -4065,20 +4059,16 @@ text_format(PG_FUNCTION_ARGS)
40654059 else
40664060 {
40674061 /*
4068- * Non-null argument had better be an array. The parser doesn't
4069- * enforce this for VARIADIC ANY functions (maybe it should?), so
4070- * that check uses ereport not just elog.
4062+ * Non-null argument had better be an array
4063+ *
4064+ * Correct values are ensured by parser check, but this function
4065+ * can be called directly, bypassing the parser, so we should do
4066+ * some minimal check too - this form of call requires correctly set
4067+ * expr argtype in flinfo.
40714068 */
4072- arr_typid = get_fn_expr_argtype (fcinfo -> flinfo , 1 );
4073- if (!OidIsValid (arr_typid ))
4074- elog (ERROR , "could not determine data type of format() input" );
4075-
4076- if (!OidIsValid (get_element_type (arr_typid )))
4077- ereport (ERROR ,
4078- (errcode (ERRCODE_DATATYPE_MISMATCH ),
4079- errmsg ("VARIADIC argument must be an array" )));
4069+ Assert (OidIsValid (get_fn_expr_argtype (fcinfo -> flinfo , 1 )));
4070+ Assert (OidIsValid (get_element_type (get_fn_expr_argtype (fcinfo -> flinfo , 1 ))));
40804071
4081- /* OK, safe to fetch the array value */
40824072 arr = PG_GETARG_ARRAYTYPE_P (1 );
40834073
40844074 /* Get info about array element type */
0 commit comments