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

Definition at line 1184 of file gserialized_gist_2d.c.

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

1185 {
1186  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1187  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1188  bool result;
1189  BOX2DF query_gbox_index;
1190 
1191  /* PostgreSQL 8.4 and later require the RECHECK flag to be set here,
1192  rather than being supplied as part of the operator class definition */
1193  bool *recheck = (bool *) PG_GETARG_POINTER(4);
1194 
1195  /* We set recheck to false to avoid repeatedly pulling every "possibly matched" geometry
1196  out during index scans. For cases when the geometries are large, rechecking
1197  can make things twice as slow. */
1198  *recheck = false;
1199 
1200  POSTGIS_DEBUG(4, "[GIST] 'consistent' function called");
1201 
1202  /* Quick sanity check on query argument. */
1203  if ( DatumGetPointer(PG_GETARG_DATUM(1)) == NULL )
1204  {
1205  POSTGIS_DEBUG(4, "[GIST] null query pointer (!?!), returning false");
1206  PG_RETURN_BOOL(false); /* NULL query! This is screwy! */
1207  }
1208 
1209  /* Quick sanity check on entry key. */
1210  if ( DatumGetPointer(entry->key) == NULL )
1211  {
1212  POSTGIS_DEBUG(4, "[GIST] null index entry, returning false");
1213  PG_RETURN_BOOL(false); /* NULL entry! */
1214  }
1215 
1216  /* Null box should never make this far. */
1217  if ( gserialized_datum_get_box2df_p(PG_GETARG_DATUM(1), &query_gbox_index) == LW_FAILURE )
1218  {
1219  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1220  PG_RETURN_BOOL(false);
1221  }
1222 
1223  /* Treat leaf node tests different from internal nodes */
1224  if (GIST_LEAF(entry))
1225  {
1227  (BOX2DF*)DatumGetPointer(entry->key),
1228  &query_gbox_index, strategy);
1229  }
1230  else
1231  {
1233  (BOX2DF*)DatumGetPointer(entry->key),
1234  &query_gbox_index, strategy);
1235  }
1236 
1237  PG_RETURN_BOOL(result);
1238 }
static bool gserialized_gist_consistent_leaf_2d(BOX2DF *key, BOX2DF *query, StrategyNumber strategy)
#define LW_FAILURE
Definition: liblwgeom.h:78
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
static bool gserialized_gist_consistent_internal_2d(BOX2DF *key, BOX2DF *query, StrategyNumber strategy)

Here is the call graph for this function: