[SCM] PostGIS branch stable-3.6 updated. 3.6.4-64-gc05f6583d
git at osgeo.org
git at osgeo.org
Sun Jul 19 04:28:10 PDT 2026
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.6 has been updated
via c05f6583d8c5e4346fe4a9d3740c2c7ca8657fb4 (commit)
via f9776f8b2fd5e924efbc3106fdeea033e38475e6 (commit)
from 8f0265779255ca22f440e383973ce8b6618ef55c (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 c05f6583d8c5e4346fe4a9d3740c2c7ca8657fb4
Merge: 8f0265779 f9776f8b2
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date: Sun Jul 19 04:28:09 2026 -0700
Merge pull request 'topology: avoid unsafe repair indexes on stable 3.6' (!433) from Komzpa/postgis:ci/backport-fixcorrupt-indexes-3.6 into stable-3.6
Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/433
commit f9776f8b2fd5e924efbc3106fdeea033e38475e6
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Mon Jul 6 11:37:12 2026 +0400
topology: avoid rebuilding unsafe repair indexes
(cherry picked from commit d45d6e66d16b6c1e6d160895269db0ef0d7d9855)
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index bdcfe70b4..cee654578 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -561,6 +561,7 @@ Rename a topology from <varname>topo_stage</varname> to <varname>topo_prod</varn
When upgrading from PostGIS topology <3.6.0 to version >3.6.0+, the topogeometry column definition was changed.
This caused corruption in topogeometries created before the upgrade. This function fixes this corruption in affected tables.
</para>
+ <para>The function refuses to process tables with expression or partial indexes; drop or rebuild those indexes manually around the repair.</para>
<!-- use this format if new function -->
<para role="availability" conformance="3.6.1">Availability: 3.6.1</para>
diff --git a/topology/sql/manage/FixCorruptTopoGeometryColumn.sql.in b/topology/sql/manage/FixCorruptTopoGeometryColumn.sql.in
index 5c5b0277c..963194a09 100644
--- a/topology/sql/manage/FixCorruptTopoGeometryColumn.sql.in
+++ b/topology/sql/manage/FixCorruptTopoGeometryColumn.sql.in
@@ -21,6 +21,33 @@ $$
DECLARE var_sql text; var_row_count bigint; result text;
BEGIN
result = '';
+ EXECUTE format('LOCK TABLE %1$I.%2$I IN SHARE ROW EXCLUSIVE MODE', layerSchema, layerTable);
+
+ IF EXISTS (
+ SELECT 1
+ FROM pg_catalog.pg_inherits inherited
+ JOIN pg_catalog.pg_class tbl ON tbl.oid = inherited.inhparent
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = tbl.relnamespace
+ WHERE nsp.nspname = layerSchema
+ AND tbl.relname = layerTable
+ ) THEN
+ RAISE EXCEPTION 'Cannot safely repair %.% while inheritance or partition child tables exist; repair each table separately',
+ layerSchema, layerTable;
+ END IF;
+
+ IF EXISTS (
+ SELECT 1
+ FROM pg_catalog.pg_index i
+ JOIN pg_catalog.pg_class tbl ON tbl.oid = i.indrelid
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = tbl.relnamespace
+ WHERE nsp.nspname = layerSchema
+ AND tbl.relname = layerTable
+ AND (i.indexprs IS NOT NULL OR i.indpred IS NOT NULL)
+ ) THEN
+ RAISE EXCEPTION 'Cannot safely repair %.% while expression or partial indexes exist; drop or rebuild those indexes manually',
+ layerSchema, layerTable;
+ END IF;
+
-- if topogeometry is bigint, then fix damaged integer, need to upgrade to bigint
IF EXISTS ( SELECT 1
FROM pg_catalog.pg_type AS pg_type
@@ -32,7 +59,7 @@ WHERE pg_type.typname = 'topogeometry' AND pga.attname = 'id'
pg_type.typnamespace::regnamespace::text = 'topology' AND pga.atttypid::regtype::text = 'bigint' ) THEN
-- correct any corrupt topogeometries and fix
- var_sql = format('UPDATE %1$I.%2$I
+ var_sql = format('UPDATE ONLY %1$I.%2$I
SET
%3$I = (
(%3$I).topology_id,
@@ -47,7 +74,7 @@ WHERE pg_type.typname = 'topogeometry' AND pga.attname = 'id'
result = result || E'\n' || format('%s rows updated for %s.%s.%s column to bigint id type', var_row_count, layerSchema, layerTable, layerColumn);
ELSE --we are coming from bigint and going back to integer
- var_sql = format('UPDATE %1$I.%2$I
+ var_sql = format('UPDATE ONLY %1$I.%2$I
SET
%3$I = (
(%3$I).topology_id,
diff --git a/topology/test/regress/hooks/hook-after-upgrade-topology.sql b/topology/test/regress/hooks/hook-after-upgrade-topology.sql
index c0c4166b6..1b5299599 100644
--- a/topology/test/regress/hooks/hook-after-upgrade-topology.sql
+++ b/topology/test/regress/hooks/hook-after-upgrade-topology.sql
@@ -1,6 +1,7 @@
SELECT * FROM topology.layer;
\d upgrade_test.feature
-- https://trac.osgeo.org/postgis/ticket/5983
+DROP INDEX upgrade_test.upgrade_test_feature_tg_id_idx;
SELECT topology.FixCorruptTopoGeometryColumn(schema_name, table_name, feature_column)
FROM topology.layer;
@@ -17,4 +18,3 @@ INSERT INTO upgrade_test.domain_test values (
SELECT * FROM upgrade_test.domain_test;
SELECT topology.DropTopology('upgrade_test');
SELECT topology.DropTopology('upgrade_test_copy');
-
diff --git a/topology/test/regress/hooks/hook-before-upgrade-topology.sql b/topology/test/regress/hooks/hook-before-upgrade-topology.sql
index fc2ffb1e8..ca6e94cee 100644
--- a/topology/test/regress/hooks/hook-before-upgrade-topology.sql
+++ b/topology/test/regress/hooks/hook-before-upgrade-topology.sql
@@ -4,7 +4,7 @@ SELECT topology.createTopology('upgrade_test');
CREATE TABLE upgrade_test.feature(id serial primary key);
SELECT topology.AddTopoGeometryColumn('upgrade_test', 'upgrade_test', 'feature', 'tg', 'linear');
INSERT INTO upgrade_test.feature(tg) SELECT topology.toTopoGeom('LINESTRING(0 0, 10 0)', 'upgrade_test', 1);
-CREATE INDEX ON upgrade_test.feature ( id(tg) );
+CREATE INDEX upgrade_test_feature_tg_id_idx ON upgrade_test.feature ( id(tg) );
-- Create some TopoGeometry data
CREATE TABLE upgrade_test.domain_test(a topology.topoelement, b topology.topoelementarray);
@@ -12,4 +12,3 @@ INSERT INTO upgrade_test.domain_test values (
'{1,2}'::topology.topoelement,
'{{2,3}}'::topology.topoelementarray
);
-
-----------------------------------------------------------------------
Summary of changes:
doc/extras_topology.xml | 1 +
.../sql/manage/FixCorruptTopoGeometryColumn.sql.in | 31 ++++++++++++++++++++--
.../regress/hooks/hook-after-upgrade-topology.sql | 2 +-
.../regress/hooks/hook-before-upgrade-topology.sql | 3 +--
4 files changed, 32 insertions(+), 5 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list