** Allows the construction of a zero-volume cube from a float[] */
| 202 | ** Allows the construction of a zero-volume cube from a float[] |
| 203 | */ |
| 204 | Datum |
| 205 | cube_a_f8(PG_FUNCTION_ARGS) |
| 206 | { |
| 207 | ArrayType *ur = PG_GETARG_ARRAYTYPE_P(0); |
| 208 | NDBOX *result; |
| 209 | int i; |
| 210 | int dim; |
| 211 | int size; |
| 212 | double *dur; |
| 213 | |
| 214 | if (array_contains_nulls(ur)) |
| 215 | ereport(ERROR, |
| 216 | (errcode(ERRCODE_ARRAY_ELEMENT_ERROR), |
| 217 | errmsg("cannot work with arrays containing NULLs"))); |
| 218 | |
| 219 | dim = ARRNELEMS(ur); |
| 220 | if (dim > CUBE_MAX_DIM) |
| 221 | ereport(ERROR, |
| 222 | (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), |
| 223 | errmsg("array is too long"), |
| 224 | errdetail("A cube cannot have more than %d dimensions.", |
| 225 | CUBE_MAX_DIM))); |
| 226 | |
| 227 | dur = ARRPTR(ur); |
| 228 | |
| 229 | size = POINT_SIZE(dim); |
| 230 | result = (NDBOX *) palloc0(size); |
| 231 | SET_VARSIZE(result, size); |
| 232 | SET_DIM(result, dim); |
| 233 | SET_POINT_BIT(result); |
| 234 | |
| 235 | for (i = 0; i < dim; i++) |
| 236 | result->x[i] = dur[i]; |
| 237 | |
| 238 | PG_RETURN_NDBOX_P(result); |
| 239 | } |
| 240 | |
| 241 | Datum |
| 242 | cube_subset(PG_FUNCTION_ARGS) |
nothing calls this directly
no test coverage detected