PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_gist_consistent()

Datum gserialized_gist_consistent ( PG_FUNCTION_ARGS  )

Definition at line 1253 of file gserialized_gist_nd.c.

References FALSE, gserialized_gist_consistent_internal(), gserialized_gist_consistent_leaf(), and LW_FAILURE.

Referenced by gserialized_gist_consistent_internal().

1254 {
1255  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1256  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1257  bool result;
1258  char gidxmem[GIDX_MAX_SIZE];
1259  GIDX *query_gbox_index = (GIDX*)gidxmem;
1260 
1261  /* PostgreSQL 8.4 and later require the RECHECK flag to be set here,
1262  rather than being supplied as part of the operator class definition */
1263  bool *recheck = (bool *) PG_GETARG_POINTER(4);
1264 
1265  /* We set recheck to false to avoid repeatedly pulling every "possibly matched" geometry
1266  out during index scans. For cases when the geometries are large, rechecking
1267  can make things twice as slow. */
1268  *recheck = false;
1269 
1270  POSTGIS_DEBUG(4, "[GIST] 'consistent' function called");
1271 
1272  /* Quick sanity check on query argument. */
1273  if ( DatumGetPointer(PG_GETARG_DATUM(1)) == NULL )
1274  {
1275  POSTGIS_DEBUG(4, "[GIST] null query pointer (!?!), returning false");
1276  PG_RETURN_BOOL(FALSE); /* NULL query! This is screwy! */
1277  }
1278 
1279  /* Quick sanity check on entry key. */
1280  if ( DatumGetPointer(entry->key) == NULL )
1281  {
1282  POSTGIS_DEBUG(4, "[GIST] null index entry, returning false");
1283  PG_RETURN_BOOL(FALSE); /* NULL entry! */
1284  }
1285 
1286  /* Null box should never make this far. */
1287  if ( gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), query_gbox_index) == LW_FAILURE )
1288  {
1289  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1290  PG_RETURN_BOOL(FALSE);
1291  }
1292 
1293  /* Treat leaf node tests different from internal nodes */
1294  if (GIST_LEAF(entry))
1295  {
1297  (GIDX*)DatumGetPointer(entry->key),
1298  query_gbox_index, strategy);
1299  }
1300  else
1301  {
1303  (GIDX*)DatumGetPointer(entry->key),
1304  query_gbox_index, strategy);
1305  }
1306 
1307  PG_RETURN_BOOL(result);
1308 }
static bool gserialized_gist_consistent_leaf(GIDX *key, GIDX *query, StrategyNumber strategy)
#define LW_FAILURE
Definition: liblwgeom.h:79
#define FALSE
Definition: dbfopen.c:168
static bool gserialized_gist_consistent_internal(GIDX *key, GIDX *query, StrategyNumber strategy)
Here is the call graph for this function:
Here is the caller graph for this function: