Skip to content

Executing custom SQL after Lua insert #1768

Answered by joto
FaFre asked this question in Q&A
Discussion options

You must be logged in to vote

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
    -- …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FaFre
Comment options

Answer selected by joto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants