Re: Multiply and Divide operators for geometry types - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Multiply and Divide operators for geometry types
Date
Msg-id 20020411030451.7a5b3629.alvherre@atentus.com
Whole thread Raw
In response to Re: Multiply and Divide operators for geometry types  (Alvaro Herrera <alvherre@atentus.com>)
Responses Re: Multiply and Divide operators for geometry types
List pgsql-general
En Thu, 11 Apr 2002 02:36:30 -0400
Alvaro Herrera <alvherre@atentus.com> escribió:

> There's something I don't quite understand here. If I do
>
> SELECT box '((2,3),(4,5))' * point '(3,4)';
>     ?column?
> -----------------
>  (-6,31),(-8,17)
>
> But my complex aritmethic gives me
>
> (-6,17),(-8,31)
>
> As I read in your mail, each point in the box gets multiplied by the
> other point, but this is not the case in the current code (CVS as of
> earlier today... well, yesterday). Is this a bug, or am I understanding
> something wrong?

Well, I don't know whether it's a bug or not, but the code has been like
this since at least 6.3, so if somebody uses this operator he surely
must be used to it being this way by this time.

Anyway, the code is (src/backend/utils/adt/geo_ops.c)

    high = DatumGetPointP(DirectFunctionCall2(point_mul,
                                              PointPGetDatum(&box->high),
                                              PointPGetDatum(p)));
    low = DatumGetPointP(DirectFunctionCall2(point_mul,
                                             PointPGetDatum(&box->low),
                                             PointPGetDatum(p)));

    result = box_construct(high->x, low->x, high->y, low->y);


which gives a nice swap in the variables, since box_construct is
prototyped as
static BOX *box_construct(double x1, double x2, double y1, double y2);

Maybe it's _supposed_ to be like this...

--
Alvaro Herrera (<alvherre[a]atentus.com>)
Officer Krupke, what are we to do?
Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Multiply and Divide operators for geometry types
Next
From: Curt Sampson
Date:
Subject: Importing Large Amounts of Data