The following bug has been logged online:
Bug reference: 4647
Logged by: Juho Saarikko
Email address: juho.saarikko@gmail.com
PostgreSQL version: 8.3.6
Operating system: Linux
Description: Geometric functions reorder their parameters randomly
Details:
According to the online documentation, the ## operator is supposed to return
"Closest point to first operand on second operand". However, in reality it
seems to decide reorder its parameters as a function of them. That is,
sometimes it returns a point on the first operand, and sometimes a point on
the second operand, depending on what those operands are, but seemingly
consistently for a given set of operands.
This behaviour is also present in 8.3.5.
PostgreSQL output (from psql) demonstrating this behaviour:
**************************************
test=# select lseg '((1,1),(1,0))' ## box '((-2,-2),(-4,-4))';
?column?
----------
(1,0)
(1 row)
test=# select lseg '((0,1),(1,0))' ## box '((-2,-2),(-4,-4))';
?column?
----------
(-2,-2)
(1 row)