Importer leaves orphaned tables behind when a layer or a zoom level goes away #12

Open
opened 2026-08-01 19:12:55 +00:00 by art-bot · 0 comments
Collaborator

Two symptoms, one root cause: the swap only ever touches the tables the current config
declares, so anything the config used to declare is left in the database forever.

  1. A layer removed from a config keeps its tables and its zxy_ functions. Unification
    Phase 2 hit this for real — ismap_/se_/plmap_background_land_* and their functions had
    to be dropped by hand, and Phases 4 and 5 paid the same tax (26 tables and 6 functions
    in one case).
  2. Lowering a layer's maxz leaves the higher zoom tables behind (e.g. old z14/z15/z16
    after lowering to z13).

Both want the same fix, in the swap transaction: drop any <prefix>_<layer>_<z> outside
the new zoom range, and drop tables/functions for layers the config no longer declares.

Be careful with the second half. A -layer import only knows about the layers it was
asked for, and several configs share one database, so "not declared by this config" is not
the same as "orphaned" — the check has to be scoped to the config's own prefix and only
run on a full import, or it will delete another country's tables. Consider making it
opt-in (-prune) rather than automatic.

Two symptoms, one root cause: the swap only ever touches the tables the *current* config declares, so anything the config used to declare is left in the database forever. 1. **A layer removed from a config** keeps its tables and its `zxy_` functions. Unification Phase 2 hit this for real — `ismap_/se_/plmap_background_land_*` and their functions had to be dropped by hand, and Phases 4 and 5 paid the same tax (26 tables and 6 functions in one case). 2. **Lowering a layer's `maxz`** leaves the higher zoom tables behind (e.g. old z14/z15/z16 after lowering to z13). Both want the same fix, in the swap transaction: drop any `<prefix>_<layer>_<z>` outside the new zoom range, and drop tables/functions for layers the config no longer declares. **Be careful with the second half.** A `-layer` import only knows about the layers it was asked for, and several configs share one database, so "not declared by this config" is not the same as "orphaned" — the check has to be scoped to the config's own prefix *and* only run on a full import, or it will delete another country's tables. Consider making it opt-in (`-prune`) rather than automatic.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
art/ismap#12
No description provided.