List:Internals« Previous MessageNext Message »
From:JJ Tavernier Date:April 12 2006 5:56am
Subject:Functions that return more than one row
View as plain text  
Hi, I'd like to add a k-Nearest Neighbor functionality to mysql for
spatial data. I'm thinking that the usage will look something like
this:

  CREATE TABLE geom2 (g GEOMETRY);

  // ... insert some data

  SET @g = GeomFromText('POINT(1 1)');
  SELECT k_nearest_neighbor(@g, 3) FROM geom2;

The k_nearest_neighbor would then return the three closest objects to
the point (1,1). From the portion of the manual on user-defined
functions (http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html), it
looks like only strings, ints and reals can be returned from
functions. How would I go about returning a row from a spatially
indexed table? How do I deal with returning multiple rows? Am I wrong
in thinking that functions are the way to go about solving this? I'm
very new to mysql development, so I would not be surprised if this is
the case.

Any help is appreciated.

Thanks,
JJ Tavernier
Thread
Functions that return more than one rowJJ Tavernier12 Apr
  • Re: Functions that return more than one rowSergei Golubchik12 Apr
    • Re: Functions that return more than one rowJJ Tavernier12 Apr
      • Re: Functions that return more than one rowSergei Golubchik16 Apr