Re: Using nulls with earthdistance operator crashes backend (patch) - Mailing list pgsql-bugs

From Mark Stosberg
Subject Re: Using nulls with earthdistance operator crashes backend (patch)
Date
Msg-id 3B7C452A.4C3F2051@summersault.com
Whole thread Raw
In response to Using nulls with earthdistance operator crashes backend  (Mark Stosberg <mark@summersault.com>)
List pgsql-bugs
> Tom Lane wrote:
> >
> > Mark Stosberg <mark@summersault.com> writes:
> > > * Install earthdistance operator from the contrib directory.
> > > * try this:
> > > cascade=> select null <@> '1,1'::point;
> >
> > > ## The result I get:
> > > pqReadData() -- backend closed the channel unexpectedly.
> >
> > Probably the earthdistance functions are not NULL-safe and need to be
> > marked "isStrict" in CREATE FUNCTION.  Would you be willing to do the
> > legwork on working up a patch for that?

Tom,

Here's a patch using "isstrict":

############
--- earthdistance.sql.in.org    Thu Aug 16 17:08:19 2001
+++ earthdistance.sql.in        Thu Aug 16 17:09:01 2001
@@ -3,7 +3,8 @@

 DROP FUNCTION geo_distance (point, point);
 CREATE FUNCTION geo_distance (point, point) RETURNS float8
-  AS 'MODULE_PATHNAME' LANGUAGE 'c';
+  AS 'MODULE_PATHNAME' LANGUAGE 'c'
+  WITH (isstrict);

 SELECT geo_distance ('(1,2)'::point, '(3,4)'::point);
#############

Now when I run the "crasher" SQL above, I get one empty row back:

sumsault_test=# select null <@> '1,1'::point;
 ?column?
----------

(1 row)
#############

I look forward to seeing you at the Open Source Database Summit!

  -mark

 . . . . . . . . . . . . . . . . . . . . . . . . . .
   Mark Stosberg              Principal Developer
   mark@summersault.com       Summersault, LLC
   v: 765-939-9301 ext 223    website development
 . . . . . http://www.summersault.com/ . . . . . . .

pgsql-bugs by date:

Previous
From: Hans Schou
Date:
Subject: linux-390-pgsql-7.1.2-make-check
Next
From: "Erik Luke"
Date:
Subject: user authentication crash