[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.6-27-g713e25639
git at osgeo.org
git at osgeo.org
Wed Aug 17 11:15:22 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.1 has been updated
via 713e25639bca30cc55d1b8b75999b37c45b1ec4e (commit)
via 6908a1e1aad632ef968d18ff09dd9c0a92f9c80c (commit)
from 53422f81d885603efaabe6486756401655ab48d8 (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 713e25639bca30cc55d1b8b75999b37c45b1ec4e
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Aug 17 11:15:15 2022 -0700
News entry for #5032
diff --git a/NEWS b/NEWS
index a4eeb9c75..88868ea49 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PostGIS 3.1.7dev
(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.1.6
2022/07/20
commit 6908a1e1aad632ef968d18ff09dd9c0a92f9c80c
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 b01bcfcba..bf90432b4 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);
@@ -2316,7 +2317,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() */
@@ -2362,13 +2363,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();
}
@@ -2434,7 +2434,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;
@@ -2473,6 +2473,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),
@@ -2482,6 +2483,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? */
@@ -2489,6 +2491,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;
@@ -2499,7 +2503,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;
@@ -2532,7 +2536,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)
@@ -2591,6 +2595,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;
@@ -2601,11 +2606,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 | 2 ++
postgis/gserialized_estimate.c | 29 +++++++++++++++++------------
2 files changed, 19 insertions(+), 12 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list