1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* geo-selfuncs.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* Selectivity routines registered in the operator catalog in the
|
|
|
|
* "oprrest" and "oprjoin" attributes.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1999-02-14 00:22:53 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.7 1999/02/13 23:19:18 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* XXX These are totally bogus.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "access/attnum.h"
|
1997-03-15 00:21:12 +01:00
|
|
|
#include "utils/geo_decls.h" /* where function declarations go */
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "utils/palloc.h"
|
1996-11-10 04:06:38 +01:00
|
|
|
#include "utils/builtins.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
float64
|
1997-09-07 07:04:48 +02:00
|
|
|
areasel(Oid opid,
|
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 4.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
float64
|
|
|
|
areajoinsel(Oid opid,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 4.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Selectivity functions for rtrees. These are bogus -- unless we know
|
|
|
|
* the actual key distribution in the index, we can't make a good prediction
|
|
|
|
* of the selectivity of these operators.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* In general, rtrees need to search multiple subtrees in order to guarantee
|
|
|
|
* that all occurrences of the same key have been found. Because of this,
|
|
|
|
* the heuristic selectivity functions we return are higher than they would
|
|
|
|
* otherwise be.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* left_sel -- How likely is a box to be strictly left of (right of, above,
|
|
|
|
* below) a given box?
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
float64
|
|
|
|
leftsel(Oid opid,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 6.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
float64
|
|
|
|
leftjoinsel(Oid opid,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 6.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* contsel -- How likely is a box to contain (be contained by) a given box?
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-08-19 23:40:56 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
float64
|
|
|
|
contsel(Oid opid,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 10.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
float64
|
|
|
|
contjoinsel(Oid opid,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attno,
|
|
|
|
char *value,
|
|
|
|
int32 flag)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
float64 result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
result = (float64) palloc(sizeof(float64data));
|
|
|
|
*result = 1.0 / 10.0;
|
1998-09-01 05:29:17 +02:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#endif
|