[postgis-devel] Function Removal

Paul Ramsey pramsey at cleverelephant.ca
Wed Dec 16 11:41:47 PST 2020


I feel like we've been over this before, but I ran into it again and I'm wondering what we think our best practice should be.

The issue is the removal of stacked multi-parameter functions. We have:

  CREATE FUNCTION ST_MakePoint(float8, float8)
  CREATE FUNCTION ST_MakePoint(float8, float8, float8)
  CREATE FUNCTION ST_MakePoint(float8, float8, float8, float8)

What's missing here? A place to set the SRID! So we constantly have this formation:

  ST_SetSRID(ST_MakePoint(...), ...)

Which is, let's face it, ugly. So being a smart boy I thought:

  CREATE FUNCTION ST_MakePoint(x float8, y float8, z float8 default null, m float8 default null, srid integer default null)

And then I updated the underlying C function to handle the nulls, and it works wonderfully:

  postgis=# select st_asewkt(ST_MakePoint(1, 2, srid => 123));
  SRID=123;POINT(1 2)

Except, unfortunately now the old form is broken.

  postgis=# select st_asewkt(ST_MakePoint(1.2, 2.33)); 
  ERROR:  function st_makepoint(double precision, double precision) is not unique
  HINT:  Could not choose a best candidate function. You might need to add explicit type casts.

Yeah, it could be either my new one or the two-parameter form of the old one.

The obvious fix would be to remove the old signatures at the same time as adding the new one, but as I recall this leads to upgrade issues? This is where my memory is failing. I know (a) a single signature with defaults and argument names is nicer and cleaner and also (b) every time I've done it there's been some kind of an outcry / mess.

Any help, thoughts?

P


More information about the postgis-devel mailing list