| 562 | */ |
| 563 | PG_FUNCTION_INFO_V1(array_max_index); |
| 564 | Datum |
| 565 | array_max_index(PG_FUNCTION_ARGS) { |
| 566 | if (PG_ARGISNULL(0)) { PG_RETURN_NULL(); } |
| 567 | ArrayType *v = PG_GETARG_ARRAYTYPE_P(0); |
| 568 | |
| 569 | if (ARR_NDIM(v) != 1) { |
| 570 | ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 571 | errmsg("Input array with multiple dimensions is not allowed!"))); |
| 572 | } |
| 573 | |
| 574 | value_index *result = (value_index *)palloc(sizeof(value_index)); |
| 575 | result->value = -get_float8_infinity(); |
| 576 | result->index = 0; |
| 577 | |
| 578 | Datum res = General_Array_to_Struct(v, result, element_argmax, value_index_finalize); |
| 579 | |
| 580 | pfree(result); |
| 581 | PG_FREE_IF_COPY(v, 0); |
| 582 | return res; |
| 583 | } |
| 584 | |
| 585 | /* |
| 586 | * This function returns minimum and corresponding index of the array elements. |
nothing calls this directly
no test coverage detected