PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gserialized_gist_consistent_2d()

Datum gserialized_gist_consistent_2d ( PG_FUNCTION_ARGS  )

Definition at line 1094 of file gserialized_gist_2d.c.

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

Referenced by gserialized_gist_consistent_internal_2d().

1095 {
1096  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1097  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1098  bool result;
1099  BOX2DF query_gbox_index;
1100 
1101  /* PostgreSQL 8.4 and later require the RECHECK flag to be set here,
1102  rather than being supplied as part of the operator class definition */
1103  bool *recheck = (bool *) PG_GETARG_POINTER(4);
1104 
1105  /* We set recheck to false to avoid repeatedly pulling every "possibly matched" geometry
1106  out during index scans. For cases when the geometries are large, rechecking
1107  can make things twice as slow. */
1108  *recheck = false;
1109 
1110  POSTGIS_DEBUG(4, "[GIST] 'consistent' function called");
1111 
1112  /* Quick sanity check on query argument. */
1113  if ( DatumGetPointer(PG_GETARG_DATUM(1)) == NULL )
1114  {
1115  POSTGIS_DEBUG(4, "[GIST] null query pointer (!?!), returning false");
1116  PG_RETURN_BOOL(FALSE); /* NULL query! This is screwy! */
1117  }
1118 
1119  /* Quick sanity check on entry key. */
1120  if ( DatumGetPointer(entry->key) == NULL )
1121  {
1122  POSTGIS_DEBUG(4, "[GIST] null index entry, returning false");
1123  PG_RETURN_BOOL(FALSE); /* NULL entry! */
1124  }
1125 
1126  /* Null box should never make this far. */
1127  if ( gserialized_datum_get_box2df_p(PG_GETARG_DATUM(1), &query_gbox_index) == LW_FAILURE )
1128  {
1129  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1130  PG_RETURN_BOOL(FALSE);
1131  }
1132 
1133  /* Treat leaf node tests different from internal nodes */
1134  if (GIST_LEAF(entry))
1135  {
1137  (BOX2DF*)DatumGetPointer(entry->key),
1138  &query_gbox_index, strategy);
1139  }
1140  else
1141  {
1143  (BOX2DF*)DatumGetPointer(entry->key),
1144  &query_gbox_index, strategy);
1145  }
1146 
1147  PG_RETURN_BOOL(result);
1148 }
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.
#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:
Here is the caller graph for this function: