[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.2-26-gd51822cf7
git at osgeo.org
git at osgeo.org
Wed Aug 17 11:14:35 PDT 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, stable-3.2 has been updated
via d51822cf772e54d9c114a12a49fb2207d1092280 (commit)
via eb871d03f343b38c6a2640e07804fd44faf1287e (commit)
from 64a87d0321ca409f8246721784580ad0812fad4a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d51822cf772e54d9c114a12a49fb2207d1092280
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Aug 17 11:14:29 2022 -0700
News entry for #5032
diff --git a/NEWS b/NEWS
index dab9cf4f2..a7457dab1 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Proj 6.1+, and PostgreSQL 14+.
(Regina Obe, Paul Ramsey)
- #5202, Guard against downgrades (Sandro Santilli)
- #5209, #5210, Fix upgrades with CVE-2022-2625 PostgreSQL fix
+ - #5032, Correctly read extent off multi-key GIST indexes (Paul Ramsey)
PostGIS 3.2.2
commit eb871d03f343b38c6a2640e07804fd44faf1287e
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Aug 17 10:24:50 2022 -0700
Correctly read geometry extent off multi-key GIST indexes. References #5032
diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c
index d05690e0b..ae6eb5122 100644
--- a/postgis/gserialized_estimate.c
+++ b/postgis/gserialized_estimate.c
@@ -145,8 +145,9 @@ Datum _postgis_gserialized_joinsel(PG_FUNCTION_ARGS);
Datum _postgis_gserialized_stats(PG_FUNCTION_ARGS);
/* Local prototypes */
-static Oid table_get_spatial_index(Oid tbl_oid, text *col, int *key_type);
-static GBOX * spatial_index_read_extent(Oid idx_oid, int key_type);
+static Oid table_get_spatial_index(Oid tbl_oid, text *col, int *key_type, int *att_num);
+static GBOX * spatial_index_read_extent(Oid idx_oid, int key_type, int att_num);
+
/* Other prototypes */
float8 gserialized_joinsel_internal(PlannerInfo *root, List *args, JoinType jointype, int mode);
@@ -2320,7 +2321,7 @@ Datum gserialized_estimated_extent(PG_FUNCTION_ARGS)
ND_STATS *nd_stats;
GBOX *gbox = NULL;
bool only_parent = false;
- int key_type;
+ int key_type, att_num;
size_t sz;
/* We need to initialize the internal cache to access it later via postgis_oid() */
@@ -2366,13 +2367,12 @@ Datum gserialized_estimated_extent(PG_FUNCTION_ARGS)
}
/* Read the extent from the head of the spatial index, if there is one */
-#if 1
- idx_oid = table_get_spatial_index(tbl_oid, col, &key_type);
-#endif
+
+ idx_oid = table_get_spatial_index(tbl_oid, col, &key_type, &att_num);
if (idx_oid)
{
/* TODO: how about only_parent ? */
- gbox = spatial_index_read_extent(idx_oid, key_type);
+ gbox = spatial_index_read_extent(idx_oid, key_type, att_num);
POSTGIS_DEBUGF(2, "index for \"%s.%s\" exists, reading gbox from there", tbl, text_to_cstring(col));
if ( ! gbox ) PG_RETURN_NULL();
}
@@ -2438,7 +2438,7 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
/************************************************************************/
static Oid
-table_get_spatial_index(Oid tbl_oid, text *col, int *key_type)
+table_get_spatial_index(Oid tbl_oid, text *col, int *key_type, int *att_num)
{
Relation tbl_rel;
ListCell *lc;
@@ -2477,6 +2477,7 @@ table_get_spatial_index(Oid tbl_oid, text *col, int *key_type)
{
Form_pg_attribute att;
Oid atttypid;
+ int attnum;
/* Is the index on the column name we are looking for? */
HeapTuple att_tup = SearchSysCache2(ATTNAME,
ObjectIdGetDatum(idx_oid),
@@ -2486,6 +2487,7 @@ table_get_spatial_index(Oid tbl_oid, text *col, int *key_type)
att = (Form_pg_attribute) GETSTRUCT(att_tup);
atttypid = att->atttypid;
+ attnum = att->attnum;
ReleaseSysCache(att_tup);
/* Is the column actually spatial? */
@@ -2493,6 +2495,8 @@ table_get_spatial_index(Oid tbl_oid, text *col, int *key_type)
{
/* Save result, clean up, and break out */
result = idx_oid;
+ if (att_num)
+ *att_num = attnum;
if (key_type)
*key_type = (atttypid == b2d_oid ? STATISTIC_KIND_2D : STATISTIC_KIND_ND);
break;
@@ -2503,7 +2507,7 @@ table_get_spatial_index(Oid tbl_oid, text *col, int *key_type)
}
static GBOX *
-spatial_index_read_extent(Oid idx_oid, int key_type)
+spatial_index_read_extent(Oid idx_oid, int key_type, int att_num)
{
BOX2DF *bounds_2df = NULL;
GIDX *bounds_gidx = NULL;
@@ -2536,7 +2540,7 @@ spatial_index_read_extent(Oid idx_oid, int key_type)
if (!GistTupleIsInvalid(ituple))
{
bool isnull;
- Datum idx_attr = index_getattr(ituple, 1, idx_rel->rd_att, &isnull);
+ Datum idx_attr = index_getattr(ituple, att_num, idx_rel->rd_att, &isnull);
if (!isnull)
{
if (key_type == STATISTIC_KIND_2D)
@@ -2595,6 +2599,7 @@ Datum _postgis_gserialized_index_extent(PG_FUNCTION_ARGS)
{
GBOX *gbox = NULL;
int key_type;
+ int att_num;
Oid tbl_oid = PG_GETARG_DATUM(0);
text *col = PG_GETARG_TEXT_P(1);
Oid idx_oid;
@@ -2605,11 +2610,11 @@ Datum _postgis_gserialized_index_extent(PG_FUNCTION_ARGS)
/* We need to initialize the internal cache to access it later via postgis_oid() */
postgis_initialize_cache();
- idx_oid = table_get_spatial_index(tbl_oid, col, &key_type);
+ idx_oid = table_get_spatial_index(tbl_oid, col, &key_type, &att_num);
if (!idx_oid)
PG_RETURN_NULL();
- gbox = spatial_index_read_extent(idx_oid, key_type);
+ gbox = spatial_index_read_extent(idx_oid, key_type, att_num);
if (!gbox)
PG_RETURN_NULL();
else
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
postgis/gserialized_estimate.c | 29 +++++++++++++++++------------
2 files changed, 18 insertions(+), 12 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list