[Tile-serving] [osm2pgsql-dev/osm2pgsql] Support for enums (Issue #2307)

Jochen Topf notifications at github.com
Thu Feb 20 14:01:44 UTC 2025


joto created an issue (osm2pgsql-dev/osm2pgsql#2307)

Enums are an interesting datatype in SQL. Enums can be created with `CREATE TYPE` in PostgreSQL. Features:

1. Storage is relatively compact, 4 bytes only. This is less than typical text labels.
2. Externally they behave mostly like text, making it easy to use.
3. Enums are sorted by internal encoding, this allows "choosing" order in a sense, for instance by "importance" in a value ("motorway" before "trunk" before "primary",...) instead of text-based ordering. This is useful for map rendering.
4. Enums can be changed with `ALTER TYPE`, for instance new values can be added, but they are still not as flexible as free text, of course.

Currently enums can be used with osm2pgsql by creating the enum type before osm2pgsql is run and then using `sql_type = 'YOUR_ENUM_TYPE'` in the table definition. After that they are used as if they were a text type.

Support in osm2pgsql could help with 
* Easier to define everything in Lua config instead of having external SQL.
* Checking values in osm2pgsql would allow for better error messages instead of failure in the COPY command.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/issues/2307
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/issues/2307 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20250220/d1227e74/attachment.htm>


More information about the Tile-serving mailing list