Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middle refactor for SQL code #2284

Merged
merged 9 commits into from
Jan 6, 2025
Merged

Conversation

joto
Copy link
Collaborator

@joto joto commented Jan 3, 2025

This PR refactors in several commits the code creating SQL queries in the middle. There are two reasons for this:

  1. This is the final change switching prepared statements from using PREPARE to using the special functions of the libpq library (see Create prepared statements via libpq instead of SQL #2118). With this change osm2pgsql should work with setups using load balancers.
  2. This moves the code generaring SQL statements from setup to the actual place where the SQL statement is used. This makes it somewhat easier to understand what's going on.

This is made possible by using a "templating engine" originally created for the generalization code which allows us to write templates of SQL code that are filled in with values for things such as "schema" or "prefix". The first commit moves this code from the "src/gen" directory into "src", futher commits refactor the code step by step.

From the "gen" directory. As preparation for using this code in the main
program.
@joto joto force-pushed the middle-prepare branch 4 times, most recently from d75969c to c1c6538 Compare January 3, 2025 14:00
joto added 8 commits January 5, 2025 15:22
It seems superfluous to have all these implementations of the set()
function, but there are some problems with MSVC 2019, and this is the
workaround. See https://developercommunity.visualstudio.com/t/10242620
Add new middle_pgsql_t::render_template() and middle_pgsql_t::dbexec()
functions and use them to create middle tables.
@lonvia lonvia merged commit 9b568ee into osm2pgsql-dev:master Jan 6, 2025
24 checks passed
@joto joto deleted the middle-prepare branch January 6, 2025 08:54
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