Patrik Sylve e6a1000155
Use pg_trigger_depth to avoid re-trigger in update (#1708)
Some of the `update_osm_${LAYER}`-functions, which are executed by triggers on updates, execute an UPDATE statement on the same tables that have these triggers. This causes the trigger functions `flag` and `store` to run multiple times for one record. 

For instance, if I add log in the trigger functions and run an INSERT on `osm_housenumber_point`, this output is generated:  

```
NOTICE:  Store
NOTICE:  Flag
NOTICE:  Refresh housenumber
NOTICE:  Flag
NOTICE:  Store
NOTICE:  Flag
INSERT 0 1
```

If we limit the triggers from executing if they are called from another trigger using `pg_trigger_depth() < 1`, the triggers will only be triggered once per record:

```
NOTICE:  Store
NOTICE:  Flag
NOTICE:  Refresh housenumber
INSERT 0 1
```

This will prevent redunant executions and might improve update performance.  

Co-authored-by: Patrik Sylve <patrik.sylve@t-kartor.com>
2025-02-18 11:18:04 +01:00
..

Mountain Peaks

Mapping Diagram

Mapping diagram for mountain peaks

ETL diagram

ETL diagram for mountain peaks