PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum gserialized_gist_consistent_2d ( PG_FUNCTION_ARGS  )

Definition at line 989 of file gserialized_gist_2d.c.

References FALSE, gserialized_datum_get_box2df_p(), gserialized_gist_consistent_internal_2d(), gserialized_gist_consistent_leaf_2d(), and LW_FAILURE.

990 {
991  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
992  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
993  bool result;
994  BOX2DF query_gbox_index;
995 
996  /* PostgreSQL 8.4 and later require the RECHECK flag to be set here,
997  rather than being supplied as part of the operator class definition */
998  bool *recheck = (bool *) PG_GETARG_POINTER(4);
999 
1000  /* We set recheck to false to avoid repeatedly pulling every "possibly matched" geometry
1001  out during index scans. For cases when the geometries are large, rechecking
1002  can make things twice as slow. */
1003  *recheck = false;
1004 
1005  POSTGIS_DEBUG(4, "[GIST] 'consistent' function called");
1006 
1007  /* Quick sanity check on query argument. */
1008  if ( DatumGetPointer(PG_GETARG_DATUM(1)) == NULL )
1009  {
1010  POSTGIS_DEBUG(4, "[GIST] null query pointer (!?!), returning false");
1011  PG_RETURN_BOOL(FALSE); /* NULL query! This is screwy! */
1012  }
1013 
1014  /* Quick sanity check on entry key. */
1015  if ( DatumGetPointer(entry->key) == NULL )
1016  {
1017  POSTGIS_DEBUG(4, "[GIST] null index entry, returning false");
1018  PG_RETURN_BOOL(FALSE); /* NULL entry! */
1019  }
1020 
1021  /* Null box should never make this far. */
1022  if ( gserialized_datum_get_box2df_p(PG_GETARG_DATUM(1), &query_gbox_index) == LW_FAILURE )
1023  {
1024  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1025  PG_RETURN_BOOL(FALSE);
1026  }
1027 
1028  /* Treat leaf node tests different from internal nodes */
1029  if (GIST_LEAF(entry))
1030  {
1032  (BOX2DF*)DatumGetPointer(entry->key),
1033  &query_gbox_index, strategy);
1034  }
1035  else
1036  {
1038  (BOX2DF*)DatumGetPointer(entry->key),
1039  &query_gbox_index, strategy);
1040  }
1041 
1042  PG_RETURN_BOOL(result);
1043 }
static bool gserialized_gist_consistent_leaf_2d(BOX2DF *key, BOX2DF *query, StrategyNumber strategy)
#define LW_FAILURE
Definition: liblwgeom.h:64
static int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
#define FALSE
Definition: dbfopen.c:168
static bool gserialized_gist_consistent_internal_2d(BOX2DF *key, BOX2DF *query, StrategyNumber strategy)

Here is the call graph for this function: