pgsql: Refactor geometric functions and operators

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor geometric functions and operators
Date: 2018-07-29 00:43:29
Message-ID: E1fjZo1-00019i-GG@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Refactor geometric functions and operators

The primary goal of this patch is to eliminate duplicate code and share
code between different geometric data types more often, to prepare the
ground for additional patches. Until now the code reuse was limited,
probably because the simpler types (line and point) were implemented
after the more complex ones.

The changes are quite extensive and can be summarised as:

* Eliminate SQL-level function calls.
* Re-use more functions to implement others.
* Unify internal function names and signatures.
* Remove private functions from geo_decls.h.
* Replace should-not-happen checks with assertions.
* Add comments describe for various functions.
* Remove some unreachable code.
* Define delimiter symbols of line datatype like the other ones.
* Remove the GEODEBUG macro and printf() calls.
* Unify code style of a few oddly formatted lines.

While the goal was to cause minimal user-visible changes, it was not
possible to keep the original behavior in all cases - for example when
handling NaN values, or when reusing code makes the functions return
consistent results.

Author: Emre Hasegeli
Reviewed-by: Kyotaro Horiguchi, me

Discussion: https://www.postgresql.org/message-id/CAE2gYzxF7-5djV6-cEvqQu-fNsnt%3DEqbOURx7ZDg%2BVv6ZMTWbg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a7dc63d904a6044d299aebdf59ad3199b6a9e99d

Modified Files
--------------
src/backend/utils/adt/geo_ops.c | 1882 +++++++++++++++++-------------------
src/backend/utils/adt/geo_spgist.c | 3 +-
src/include/utils/geo_decls.h | 4 -
src/test/regress/regress.c | 7 +-
4 files changed, 870 insertions(+), 1026 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2018-07-29 01:43:52 pgsql: Provide separate header file for built-in float types
Previous Message Michael Paquier 2018-07-28 22:58:00 pgsql: Add verbosity to pg_basebackup for sync

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-07-29 01:00:05 Re: Making "COPY partitioned_table FROM" faster
Previous Message Fabien COELHO 2018-07-29 00:11:17 Re: Usability fail with psql's \dp command