[PostGIS] #5983: Data corruption in topology.topoelement and topology.topogeometry after upgrade to 3.6.0

PostGIS trac at osgeo.org
Fri Oct 17 09:02:59 PDT 2025


#5983: Data corruption in topology.topoelement and topology.topogeometry after
upgrade to 3.6.0
-----------------------+---------------------------
  Reporter:  packi     |      Owner:  robe
      Type:  defect    |     Status:  new
  Priority:  blocker   |  Milestone:  PostGIS 3.6.1
 Component:  topology  |    Version:  3.6.x
Resolution:            |   Keywords:
-----------------------+---------------------------
Comment (by francoisb):

 FWIW, in my database (PostgreSQL 16.10, macOS), I was able to recover the
 topogeometry columns with these two steps:

 1) Upgrade the topology to use the bigint feature:

 {{{
 SELECT UpgradeTopology('topo_1');
 }}}

 Note I'm not 100% sure this step is actually needed, but I add it here
 because I did it. We could test without, and perhaps remove it.

 2) Recover `id` and `type` values from the bytes of corrupted `id`, with a
 query like:

 {{{
 UPDATE table_1
 SET
   topogeom = (
     (topogeom).topology_id,
     (topogeom).layer_id,
     (topogeom).id & 0xFFFFFFFF, -- 32 least significant bits from
 corrupted "id"
     (topogeom).id >> 32         -- 32 most significant bits from corrupted
 "id"
   )::topogeometry
 WHERE topogeom IS NOT NULL
 RETURNING topogeom;
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5983#comment:19>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list