----------------------------------------------------------------------------- * array_cat : * concatenate two nD arrays to form an nD array, or * push an (n-1)D array onto the end of an nD array *---------------------------------------------------------------------------- */
| 236 | *---------------------------------------------------------------------------- |
| 237 | */ |
| 238 | Datum |
| 239 | array_cat(PG_FUNCTION_ARGS) |
| 240 | { |
| 241 | ArrayType *v1, |
| 242 | *v2; |
| 243 | ArrayType *result; |
| 244 | int *dims, |
| 245 | *lbs, |
| 246 | ndims, |
| 247 | nitems, |
| 248 | ndatabytes, |
| 249 | nbytes; |
| 250 | int *dims1, |
| 251 | *lbs1, |
| 252 | ndims1, |
| 253 | nitems1, |
| 254 | ndatabytes1; |
| 255 | int *dims2, |
| 256 | *lbs2, |
| 257 | ndims2, |
| 258 | nitems2, |
| 259 | ndatabytes2; |
| 260 | int i; |
| 261 | char *dat1, |
| 262 | *dat2; |
| 263 | bits8 *bitmap1, |
| 264 | *bitmap2; |
| 265 | Oid element_type; |
| 266 | Oid element_type1; |
| 267 | Oid element_type2; |
| 268 | int32 dataoffset; |
| 269 | |
| 270 | /* Concatenating a null array is a no-op, just return the other input */ |
| 271 | if (PG_ARGISNULL(0)) |
| 272 | { |
| 273 | if (PG_ARGISNULL(1)) |
| 274 | PG_RETURN_NULL(); |
| 275 | result = PG_GETARG_ARRAYTYPE_P(1); |
| 276 | PG_RETURN_ARRAYTYPE_P(result); |
| 277 | } |
| 278 | if (PG_ARGISNULL(1)) |
| 279 | { |
| 280 | result = PG_GETARG_ARRAYTYPE_P(0); |
| 281 | PG_RETURN_ARRAYTYPE_P(result); |
| 282 | } |
| 283 | |
| 284 | v1 = PG_GETARG_ARRAYTYPE_P(0); |
| 285 | v2 = PG_GETARG_ARRAYTYPE_P(1); |
| 286 | |
| 287 | element_type1 = ARR_ELEMTYPE(v1); |
| 288 | element_type2 = ARR_ELEMTYPE(v2); |
| 289 | |
| 290 | /* Check we have matching element types */ |
| 291 | if (element_type1 != element_type2) |
| 292 | ereport(ERROR, |
| 293 | (errcode(ERRCODE_DATATYPE_MISMATCH), |
| 294 | errmsg("cannot concatenate incompatible arrays"), |
| 295 | errdetail("Arrays with element types %s and %s are not " |
nothing calls this directly
no test coverage detected