| 587 | */ |
| 588 | PG_FUNCTION_INFO_V1(array_min_index); |
| 589 | Datum |
| 590 | array_min_index(PG_FUNCTION_ARGS) { |
| 591 | if (PG_ARGISNULL(0)) { PG_RETURN_NULL(); } |
| 592 | ArrayType *v = PG_GETARG_ARRAYTYPE_P(0); |
| 593 | |
| 594 | if (ARR_NDIM(v) != 1) { |
| 595 | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 596 | errmsg("Input array with multiple dimensions is not allowed!"))); |
| 597 | } |
| 598 | |
| 599 | value_index *result = (value_index *)palloc(sizeof(value_index)); |
| 600 | result->value = get_float8_infinity(); |
| 601 | result->index = 0; |
| 602 | |
| 603 | Datum res = General_Array_to_Struct(v, result, element_argmin, value_index_finalize); |
| 604 | |
| 605 | PG_FREE_IF_COPY(v, 0); |
| 606 | |
| 607 | pfree(result); |
| 608 | return res; |
| 609 | } |
| 610 | |
| 611 | /* |
| 612 | * This function returns dot product of two arrays as vectors. |
nothing calls this directly
no test coverage detected