1266{
1267 GISTENTRY *entry = (GISTENTRY *)PG_GETARG_POINTER(0);
1268 Datum query_datum = PG_GETARG_DATUM(1);
1269 StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
1270 bool *recheck = (bool *)PG_GETARG_POINTER(4);
1271 char query_box_mem[GIDX_MAX_SIZE];
1272 GIDX *query_box = (GIDX *)query_box_mem;
1273 GIDX *entry_box;
1275
1276 POSTGIS_DEBUGF(3, "[GIST] '%s' function called", __func__);
1277
1278
1279 if (strategy != 13)
1280 {
1281 elog(ERROR, "unrecognized strategy number: %d", strategy);
1282 PG_RETURN_FLOAT8(FLT_MAX);
1283 }
1284
1285
1286 if (gserialized_datum_get_gidx_p(query_datum, query_box) ==
LW_FAILURE)
1287 {
1288 POSTGIS_DEBUG(2, "[GIST] null query_gbox_index!");
1289 PG_RETURN_FLOAT8(FLT_MAX);
1290 }
1291
1292
1293 if (GIST_LEAF(entry))
1294 *recheck = true;
1295
1296
1297 entry_box = (GIDX *)DatumGetPointer(entry->key);
1298
1299
1300
1301
1302
1303
1305 POSTGIS_DEBUGF(2,
"[GIST] '%s' got distance %g", __func__,
distance);
1306
1308}
static double gidx_distance(const GIDX *a, const GIDX *b, int m_is_time)
Calculate the box->box distance.
static double distance(double x1, double y1, double x2, double y2)