|
208 | 208 | </tgroup>
|
209 | 209 | </table>
|
210 | 210 |
|
211 |
| - <para> |
212 |
| - Currently, ordering by the distance operator <literal><-></> |
213 |
| - is supported only with <literal>point</> by the operator classes |
214 |
| - of the geometric types. |
215 |
| - </para> |
216 |
| - |
217 | 211 | <para>
|
218 | 212 | For historical reasons, the <literal>inet_ops</> operator class is
|
219 | 213 | not the default class for types <type>inet</> and <type>cidr</>.
|
@@ -805,28 +799,30 @@ my_distance(PG_FUNCTION_ARGS)
|
805 | 799 | </para>
|
806 | 800 |
|
807 | 801 | <para>
|
808 |
| - Some approximation is allowed when determining the distance,as long as |
809 |
| - the result is never greater than the entry's actual distance. Thus, for |
810 |
| - example, distance to a bounding box is usually sufficient in geometric |
811 |
| - applications. For an internal tree node, the distance returned must not |
812 |
| - be greater than the distance to any of the child nodes. If the returned |
813 |
| - distance is notaccurate, the function must set *recheck to false. (This |
814 |
| - is not necessary for internal tree nodes; for them, the calculation is |
815 |
| - always assumed to beinaccurate). The executor will calculate the |
816 |
| -accurate distance after fetchingthetuple fromtheheap, and reorder |
817 |
| - the tuples if necessary. |
| 802 | + Some approximation is allowed when determining the distance,so long |
| 803 | +asthe result is never greater than the entry's actual distance. Thus, |
| 804 | +forexample, distance to a bounding box is usually sufficient in |
| 805 | +geometricapplications. For an internal tree node, the distance |
| 806 | +returned must notbe greater than the distance to any of the child |
| 807 | +nodes. If the returneddistance is notexact, the function must set |
| 808 | +<literal>*recheck</> to true. (Thisis not necessary for internal tree |
| 809 | +nodes; for them, the calculation isalways assumed to beinexact.) In |
| 810 | +this casetheexecutor will calculatetheaccurate distance after |
| 811 | +fetching the tuple from the heap, and reorderthe tuples if necessary. |
818 | 812 | </para>
|
819 | 813 |
|
820 | 814 | <para>
|
821 |
| - If the distance function returns *recheck=true for a leaf node, the |
822 |
| - original ordering operator's return type must be float8 or float4, and |
823 |
| - the distance function's return value must be comparable with the actual |
824 |
| - distance operator. Otherwise, the distance function's return type can |
825 |
| - be any finit <type>float8</> value, as long as the relative order of |
826 |
| - the returned values matches the order returned by the ordering operator. |
827 |
| - (Infinity and minus infinity are used internally to handle cases such as |
828 |
| - nulls, so it is not recommended that <function>distance</> functions |
829 |
| - return these values.) |
| 815 | + If the distance function returns <literal>*recheck = true</> for any |
| 816 | + leaf node, the original ordering operator's return type must |
| 817 | + be <type>float8</> or <type>float4</>, and the distance function's |
| 818 | + result values must be comparable to those of the original ordering |
| 819 | + operator, since the executor will sort using both distance function |
| 820 | + results and recalculated ordering-operator results. Otherwise, the |
| 821 | + distance function's result values can be any finite <type>float8</> |
| 822 | + values, so long as the relative order of the result values matches the |
| 823 | + order returned by the ordering operator. (Infinity and minus infinity |
| 824 | + are used internally to handle cases such as nulls, so it is not |
| 825 | + recommended that <function>distance</> functions return these values.) |
830 | 826 | </para>
|
831 | 827 |
|
832 | 828 | </listitem>
|
@@ -857,7 +853,7 @@ LANGUAGE C STRICT;
|
857 | 853 | struct, whose 'key' field contains the same datum in the original,
|
858 | 854 | uncompressed form. If the opclass' compress function does nothing for
|
859 | 855 | leaf entries, the fetch method can return the argument as is.
|
860 |
| - </para> |
| 856 | + </para> |
861 | 857 |
|
862 | 858 | <para>
|
863 | 859 | The matching code in the C module could then follow this skeleton:
|
|