opengeospatial / geopackage

An asciidoc version of the GeoPackage specification for easier collaboration
https://www.geopackage.org
Other
264 stars 71 forks source link

RTree update6 spec issue in GeoPackage 1.4.0 #672

Closed bosborn closed 10 months ago

bosborn commented 10 months ago

I think the RTree update table in update6 should be rtree_<t>_<c> instead of <t>. Otherwise it causes errors such as SQL error or missing database (no such column: minx) attempting to update non existing min/max x/y columns on the feature table instead of the RTree.

Change this...

CREATE TRIGGER rtree_<t>_<c>_update6 AFTER UPDATE OF <c> ON <t>
  WHEN OLD.<i> = NEW.<i> AND
       (NEW.<c> NOTNULL AND NOT ST_IsEmpty(NEW.<c>)) AND
       (OLD.<c> NOTNULL AND NOT ST_IsEmpty(OLD.<c>))
BEGIN
  UPDATE <t> SET
    minx = ST_MinX(NEW.<c>),
    maxx = ST_MaxX(NEW.<c>),
    miny = ST_MinY(NEW.<c>),
    maxy = ST_MaxY(NEW.<c>)
  WHERE id = NEW.<i>;
END;

to this...

CREATE TRIGGER rtree_<t>_<c>_update6 AFTER UPDATE OF <c> ON <t>
  WHEN OLD.<i> = NEW.<i> AND
       (NEW.<c> NOTNULL AND NOT ST_IsEmpty(NEW.<c>)) AND
       (OLD.<c> NOTNULL AND NOT ST_IsEmpty(OLD.<c>))
BEGIN
  UPDATE rtree_<t>_<c> SET
    minx = ST_MinX(NEW.<c>),
    maxx = ST_MaxX(NEW.<c>),
    miny = ST_MinY(NEW.<c>),
    maxy = ST_MaxY(NEW.<c>)
  WHERE id = NEW.<i>;
END;