| 5964 | } |
| 5965 | |
| 5966 | static ArrayType * |
| 5967 | array_fill_internal(ArrayType *dims, ArrayType *lbs, |
| 5968 | Datum value, bool isnull, Oid elmtype, |
| 5969 | FunctionCallInfo fcinfo) |
| 5970 | { |
| 5971 | ArrayType *result; |
| 5972 | int *dimv; |
| 5973 | int *lbsv; |
| 5974 | int ndims; |
| 5975 | int nitems; |
| 5976 | int deflbs[MAXDIM]; |
| 5977 | int16 elmlen; |
| 5978 | bool elmbyval; |
| 5979 | char elmalign; |
| 5980 | ArrayMetaState *my_extra; |
| 5981 | |
| 5982 | /* |
| 5983 | * Params checks |
| 5984 | */ |
| 5985 | if (ARR_NDIM(dims) > 1) |
| 5986 | ereport(ERROR, |
| 5987 | (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), |
| 5988 | errmsg("wrong number of array subscripts"), |
| 5989 | errdetail("Dimension array must be one dimensional."))); |
| 5990 | |
| 5991 | if (array_contains_nulls(dims)) |
| 5992 | ereport(ERROR, |
| 5993 | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| 5994 | errmsg("dimension values cannot be null"))); |
| 5995 | |
| 5996 | dimv = (int *) ARR_DATA_PTR(dims); |
| 5997 | ndims = (ARR_NDIM(dims) > 0) ? ARR_DIMS(dims)[0] : 0; |
| 5998 | |
| 5999 | if (ndims < 0) /* we do allow zero-dimension arrays */ |
| 6000 | ereport(ERROR, |
| 6001 | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 6002 | errmsg("invalid number of dimensions: %d", ndims))); |
| 6003 | if (ndims > MAXDIM) |
| 6004 | ereport(ERROR, |
| 6005 | (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
| 6006 | errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", |
| 6007 | ndims, MAXDIM))); |
| 6008 | |
| 6009 | if (lbs != NULL) |
| 6010 | { |
| 6011 | if (ARR_NDIM(lbs) > 1) |
| 6012 | ereport(ERROR, |
| 6013 | (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), |
| 6014 | errmsg("wrong number of array subscripts"), |
| 6015 | errdetail("Dimension array must be one dimensional."))); |
| 6016 | |
| 6017 | if (array_contains_nulls(lbs)) |
| 6018 | ereport(ERROR, |
| 6019 | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| 6020 | errmsg("dimension values cannot be null"))); |
| 6021 | |
| 6022 | if (ndims != ((ARR_NDIM(lbs) > 0) ? ARR_DIMS(lbs)[0] : 0)) |
| 6023 | ereport(ERROR, |
no test coverage detected