Proposed patch for contrib/cube

Started by Joshua Reichover 19 years ago4 messages
#1Joshua Reich
josh@root.net
1 attachment(s)

Hi,

I use the cube datatype a fair bit, and one thing I have always wanted
is the ability to do this:

pg=# select cube_from_arrays('{1,2,3}'::float[], '{3,5,6}'::float[]);
cube_from_arrays
---------------------
(1, 2, 3),(3, 5, 6)
(1 row)

That is - build a cube by specifying 2 arrays, one for the UR
coordinate, one for LL.

I hope people find this useful, and if so, we can add it to contrib/cube.

Source is attached.

Thanks,

Joshua Reich
(jdigittl on #postgresql)

Attachments:

cube_from_arrays.ctext/plain; name=cube_from_arrays.c; x-mac-creator=0; x-mac-type=0Download
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joshua Reich (#1)
Re: Proposed patch for contrib/cube

Joshua Reich <josh@root.net> writes:

... build a cube by specifying 2 arrays, one for the UR
coordinate, one for LL.
I hope people find this useful, and if so, we can add it to contrib/cube.

Seems useful, but it needs work: it will fail on toasted arrays or
arrays containing nulls. I'd suggest converting it to V1 call protocol
too, as the V1 GETARG macros are the easiest answer to the toasting
problem. Null array elements are a new issue in CVS HEAD, you'd need
to test against HEAD for that.

As a matter of style, would it be better to error out if the arrays
are not the same length?

regards, tom lane

#3Joshua Reich
josh@root.net
In reply to: Tom Lane (#2)
1 attachment(s)
Re: Proposed patch for contrib/cube

Tom: Thanks for the out-of-band posting to the documentation. I think
the new version (attached) addresses your issues.

What is the general process for submitting patches? Is there a URL
someone can point me towards to learn more?

Thanks,

Josh Reich

Tom Lane wrote:

Show quoted text

Joshua Reich <josh@root.net> writes:

... build a cube by specifying 2 arrays, one for the UR
coordinate, one for LL.
I hope people find this useful, and if so, we can add it to contrib/cube.

Seems useful, but it needs work: it will fail on toasted arrays or
arrays containing nulls. I'd suggest converting it to V1 call protocol
too, as the V1 GETARG macros are the easiest answer to the toasting
problem. Null array elements are a new issue in CVS HEAD, you'd need
to test against HEAD for that.

As a matter of style, would it be better to error out if the arrays
are not the same length?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Attachments:

cube_from_arrays.ctext/plain; name=cube_from_arrays.c; x-mac-creator=0; x-mac-type=0Download
#4Josh Berkus
josh@agliodbs.com
In reply to: Joshua Reich (#3)
Re: Proposed patch for contrib/cube

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.

--
--Josh

Josh Berkus
PostgreSQL @ Sun
San Francisco