PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_gist_consistent_2d()

Datum gserialized_gist_consistent_2d ( PG_FUNCTION_ARGS  )

Definition at line 1129 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().

1130 {
1131  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1132  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1133  bool result;
1134  BOX2DF query_gbox_index;
1135 
1136  /* PostgreSQL 8.4 and later require the RECHECK flag to be set here,
1137  rather than being supplied as part of the operator class definition */
1138  bool *recheck = (bool *) PG_GETARG_POINTER(4);
1139 
1140  /* We set recheck to false to avoid repeatedly pulling every "possibly matched" geometry
1141  out during index scans. For cases when the geometries are large, rechecking
1142  can make things twice as slow. */
1143  *recheck = false;
1144 
1145  POSTGIS_DEBUG(4, "[GIST] 'consistent' function called");
1146 
1147  /* Quick sanity check on query argument. */
1148  if ( DatumGetPointer(PG_GETARG_DATUM(1)) == NULL )
1149  {
1150  POSTGIS_DEBUG(4, "[GIST] null query pointer (!?!), returning false");
1151  PG_RETURN_BOOL(FALSE); /* NULL query! This is screwy! */
1152  }
1153 
1154  /* Quick sanity check on entry key. */
1155  if ( DatumGetPointer(entry->key) == NULL )
1156  {
1157  POSTGIS_DEBUG(4, "[GIST] null index entry, returning false");
1158  PG_RETURN_BOOL(FALSE); /* NULL entry! */
1159  }
1160 
1161  /* Null box should never make this far. */
1162  if ( gserialized_datum_get_box2df_p(PG_GETARG_DATUM(1), &query_gbox_index) == LW_FAILURE )
1163  {
1164  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1165  PG_RETURN_BOOL(FALSE);
1166  }
1167 
1168  /* Treat leaf node tests different from internal nodes */
1169  if (GIST_LEAF(entry))
1170  {
1172  (BOX2DF*)DatumGetPointer(entry->key),
1173  &query_gbox_index, strategy);
1174  }
1175  else
1176  {
1178  (BOX2DF*)DatumGetPointer(entry->key),
1179  &query_gbox_index, strategy);
1180  }
1181 
1182  PG_RETURN_BOOL(result);
1183 }
static bool gserialized_gist_consistent_leaf_2d(BOX2DF *key, BOX2DF *query, StrategyNumber strategy)
#define LW_FAILURE
Definition: liblwgeom.h:79
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: