Proposed patch for contrib/cube - Mailing list pgsql-patches
From | Joshua Reich |
---|---|
Subject | Proposed patch for contrib/cube |
Date | |
Msg-id | 44BC0749.7040105@root.net Whole thread Raw |
Responses |
Re: Proposed patch for contrib/cube
(Neil Conway <neilc@samurai.com>)
Re: Proposed patch for contrib/cube (Tom Lane <tgl@sss.pgh.pa.us>) |
List | pgsql-patches |
Ok. So, the cube code looks very unmaintained (not to offend anyone), but it is all in V0 and I believe make installcheck fails out of the box due to new error message formats. I'm in the process of twisting the arm of another guy here to help me clean up the code - if that is ok with the powers that be? While we are working on that, here is a patch for contrib/cube that allows you to create a cube from 2 float[]'s. This avoids an ugly step of casting arrays to varchars, and then replacing the {'s with ('s... This is my first patch submission, so please let me know what heinous errors I have made, and if I'm not too battered after the process I'll begin the cleanup of the contrib/cube tree. Thanks all! Josh Reich Josh Berkus wrote: > Josh, > >> What is the general process for submitting patches? Is there a URL >> someone can point me towards to learn more? > > Send them in an e-mail to pgsql-patches. > -- Joshua Reich Finance and Corporate Development ROOT Exchange, A Division of ROOT Markets 601 W. 26th St. / Suite 1500 New York, NY 10001 W - (212) 645 6320 x 7101 M / T - (646) 427 7959 E - josh@rootexchange.com 15a16,17 > #include "utils/array.h" > #include "fmgr.h" 37a40,44 > /* > ** Input/Output routines (V1 call protocol) > */ > PG_FUNCTION_INFO_V1(cube_from_arrays); > 169a177,235 > /* > ** Taken from the intarray contrib header > */ > #define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) ) > #define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x)) > > > /* > ** Allows the construction of a cube from 2 float[]'s > */ > NDBOX * > cube_from_arrays (PG_FUNCTION_ARGS) > { > int i; > int dim; > int size; > NDBOX *result; > ArrayType *ur, *ll; > double *dur, *dll; > > if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) > { > ereport(ERROR, > (errcode(ERRCODE_ARRAY_ELEMENT_ERROR), > errmsg("Cannot work with NULL arrays"))); > } > > ur = (ArrayType *) PG_GETARG_VARLENA_P(0); > ll = (ArrayType *) PG_GETARG_VARLENA_P(1); > > dim = ARRNELEMS(ur); > if (ARRNELEMS(ll) != dim) > { > ereport(ERROR, > (errcode(ERRCODE_ARRAY_ELEMENT_ERROR), > errmsg("UR and LL arrays must be of same length"))); > > PG_RETURN_NULL(); > } > > dur = ARRPTR(ur); > dll = ARRPTR(ll); > > size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim; > result = (NDBOX *) palloc (size); > memset (result, 0, size); > result->size = size; > result->dim = dim; > > for (i=0; i<dim; i++) > { > result->x[i] = dur[i]; > result->x[i+dim] = dll[i]; > } > > PG_RETURN_DATUM(result); > } > > 25a26,31 > -- Convert float arrays to cube > > CREATE OR REPLACE FUNCTION cube_from_arrays(float[], float[]) RETURNS cube > AS 'MODULE_PATHNAME' > LANGUAGE 'C' IMMUTABLE STRICT; >
pgsql-patches by date: