*
**********************************************************************
* $Log$
+ * Revision 1.22 2004/06/08 17:49:14 strk
+ * Fixed to build cleanly agains pg75
+ *
* Revision 1.21 2004/04/28 22:26:02 pramsey
* Fixed spelling mistake in header text.
*
#else // USE_VERSION >= 75
+
+/*------------ COPIED AND ADAPTED FROM POSTGRESQL --------*/
+
+/*
+ * Locate the n'th cell (counting from 0) of the list. It is an assertion
+ * error if there isn't one.
+ */
+static ListCell *
+list_nth_cell(List *list, int n)
+{
+ ListCell *match;
+
+ /* Does the caller actually mean to fetch the tail? */
+ if (n == list->length - 1)
+ return list->tail;
+
+ for (match = list->head; n-- > 0; match = match->next)
+ ;
+
+ return match;
+}
+
+/*
+ * Return the data value contained in the n'th element of the
+ * specified list. (List elements begin at 0.)
+ */
+void *
+list_nth(List *list, int n)
+{
+ return lfirst(list_nth_cell(list, n));
+}
+
+/*------------ END COPIED AND ADAPTED FROM POSTGRESQL --------*/
+
+
/*
* This function should return an estimation of the number of
* rows returned by a query involving an overlap check
HeapTuple stats_tuple;
GEOM_STATS *geomstats;
int geomstats_nvalues=0;
- Const *other;
+ Node *other;
Var *self;
GEOMETRY *in;
BOX *search_box;
elog(NOTICE, "postgis_gist_sel called");
#endif
+ /* Fail if not a binary opclause (probably shouldn't happen) */
+ if (list_length(args) != 2)
+ {
+#if DEBUG_GEOMETRY_STATS
+ elog(NOTICE, "postgis_gist_sel: not a binary opclause");
+#endif
+ PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_SEL);
+ }
+
+
/*
* Find the constant part
*/
-
- other = (Const *) lfirst(args);
+ other = (Node *) linitial(args);
if ( ! IsA(other, Const) )
{
self = (Var *)other;
- other = (Const *) lsecond(args);
+ other = (Node *) lsecond(args);
}
else
{
*/
relid = getrelid(varRelid, root->rtable);
+
stats_tuple = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid), Int16GetDatum(self->varattno), 0, 0);
if ( ! stats_tuple )
{