pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Improve contrib/cube's handling of zero-D cubes, infinities, and
Date: Tue, 27 Sep 2016 15:38:48 +0000
Message-ID: <E1bouT2-0008SG-OE@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Improve contrib/cube's handling of zero-D cubes, infinities, and NaNs.

It's always been possible to create a zero-dimensional cube by converting
from a zero-length float8 array, but cube_in failed to accept the '()'
representation that cube_out produced for that case, resulting in a
dump/reload hazard.  Make it accept the case.  Also fix a couple of
other places that didn't behave sanely for zero-dimensional cubes:
cube_size would produce 1.0 when surely the answer should be 0.0,
and g_cube_distance risked a divide-by-zero failure.

Likewise, it's always been possible to create cubes containing float8
infinity or NaN coordinate values, but cube_in couldn't parse such input,
and cube_out produced platform-dependent spellings of the values.  Convert
them to use float8in_internal and float8out_internal so that the behavior
will be the same as for float8, as we recently did for the core geometric
types (cf commit 50861cd68).  As in that commit, I don't pretend that this
patch fixes all insane corner-case behaviors that may exist for NaNs, but
it's a step forward.

(This change allows removal of the separate cube_1.out and cube_3.out
expected-files, as the platform dependency that previously required them
is now gone: an underflowing coordinate value will now produce an error
not plus or minus zero.)

Make errors from cube_in follow project conventions as to spelling
("invalid input syntax for cube" not "bad cube representation")
and errcode (INVALID_TEXT_REPRESENTATION not SYNTAX_ERROR).

Also a few marginal code cleanups and comment improvements.

Tom Lane, reviewed by Amul Sul

Discussion: <15085.1472494782@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f31a931fade868d788ef4480c59753a2d5059246

Modified Files
--------------
contrib/cube/cube.c              |   70 +-
contrib/cube/cubedata.h          |    7 +
contrib/cube/cubeparse.y         |  148 ++--
contrib/cube/cubescan.l          |   15 +-
contrib/cube/expected/cube.out   |  115 ++-
contrib/cube/expected/cube_1.out | 1710 --------------------------------------
contrib/cube/expected/cube_2.out |  115 ++-
contrib/cube/expected/cube_3.out | 1710 --------------------------------------
contrib/cube/sql/cube.sql        |   11 +-
9 files changed, 275 insertions(+), 3626 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1bouT2-0008SG-OE@gemulon.postgresql.org>
Permalink:  ../E1bouT2-0008SG-OE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1bouT2-0008SG-OE@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Improve contrib/cube's handling of zero-D cubes, infinities, and
  In-Reply-To: <E1bouT2-0008SG-OE@gemulon.postgresql.org>
  References: <E1bouT2-0008SG-OE@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox