[Tile-serving] [openstreetmap/osm2pgsql] Executing custom SQL after Lua insert (Discussion #1768)

Jochen Topf notifications at github.com
Mon Sep 19 15:32:09 UTC 2022


Do you actually need to do this "right after the insert"? It would be much easier to do that later. You can insert an empty column (possibly with `create_only`) that's NULL to any table to mark that work still needs to be done and run an SQL script after osm2pgsql finishes that fills in that column. Or just create a "TODO" table with a list of ids that need post-processing.

If you really need this, you can build yourself a "start" callback by checking that the `process_node()` function is called for the first time, something like this:

```
local first_object = true
function osm2pgsql.process_node(object)
    if first_object then
        first_object = false
        process_start()
    end
    -- normal node processing
end
```

Note that doing anything with the data in the database inside the Lua processing functions is problematic (not only because of the missing indexes), because the inserts done by osm2pgsql are buffered, so changing a row directly after inserting it will not work. But it would be okay, to create a trigger inside that `process_start()` function.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/discussions/1768#discussioncomment-3682079
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/osm2pgsql/repo-discussions/1768/comments/3682079 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20220919/6402c6ac/attachment.htm>


More information about the Tile-serving mailing list