Skip to content

Replace geometry check trigger by WHERE condition on COPY - #2500

Merged
lonvia merged 1 commit into
osm2pgsql-dev:masterfrom
joto:copy-where
Sep 10, 2026
Merged

Replace geometry check trigger by WHERE condition on COPY#2500
lonvia merged 1 commit into
osm2pgsql-dev:masterfrom
joto:copy-where

Conversation

@joto

@joto joto commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Since version 12 PostgreSQL supports a WHERE condition on the COPY command. Use this to add a geometry check when adding data to the database instead of the trigger we used before.

This makes the code simpler and doesn't clutter the database with triggers.

If you have already imported a database with an older version of osm2pgsql and want to use this new version, that will still work. But the original triggers will still be there so there is some extra work done for each update. Simply remove the triggers and trigger functions from the database with commands of the form
DROP TRIGGER *_osm2pgsql_valid ON *;
DROP FUNCTION *_osm2pgsql_valid;

PostgreSQL 12 is currently the oldest database version we support.

Since version 12 PostgreSQL supports a WHERE condition on the
COPY command. Use this to add a geometry check when adding data
to the database instead of the trigger we used before.

This makes the code simpler and doesn't clutter the database with
triggers.

If you have already imported a database with an older version of
osm2pgsql and want to use this new version, that will still work. But
the original triggers will still be there so there is some extra work
done for each update. Simply remove the triggers and trigger functions
from the database with commands of the form
    DROP TRIGGER *_osm2pgsql_valid ON *;
    DROP FUNCTION *_osm2pgsql_valid;

PostgreSQL 12 is currently the oldest database version we support.

This also makes the version of the proj library osm2pgsql was compiled
with available in the Lua config as the "osm2pgsql.proj_version" string
variable. It is set to '[disabled]' if osm2pgsql was compiled without
proj support. It is needed for this so we can disable the test if proj
is not available.
@lonvia
lonvia merged commit f720d32 into osm2pgsql-dev:master Sep 10, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants