From abd65546362114d99aac2ce20733a4ca2dc20b6f Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 1 Feb 2024 10:27:24 +0100 Subject: [PATCH] Rename conninfo to connection_params everywhere This is really part of the previous commit but was factored out to keep that one reasonably legible. --- src/command-line-parser.cpp | 2 +- src/db-copy.cpp | 10 +++++----- src/db-copy.hpp | 6 +++--- src/expire-output.cpp | 11 ++++++----- src/expire-output.hpp | 6 +++--- src/flex-table.cpp | 4 ++-- src/flex-table.hpp | 2 +- src/gen/osm2pgsql-gen.cpp | 27 +++++++++++++++------------ src/middle-pgsql.cpp | 17 +++++++++-------- src/middle-pgsql.hpp | 4 ++-- src/options.hpp | 2 +- src/osm2pgsql.cpp | 5 +++-- src/osmdata.cpp | 10 ++++++---- src/osmdata.hpp | 2 +- src/output-flex.cpp | 17 +++++++++-------- src/output-gazetteer.cpp | 2 +- src/output-gazetteer.hpp | 2 +- src/output-pgsql.cpp | 6 ++++-- src/pgsql.cpp | 4 ++-- src/pgsql.hpp | 2 +- src/properties.cpp | 12 +++++++----- src/properties.hpp | 6 +++--- src/table.cpp | 10 +++++----- src/table.hpp | 4 ++-- tests/common-import.hpp | 4 ++-- tests/common-options.hpp | 2 +- tests/common-pg.hpp | 4 ++-- tests/test-db-copy-mgr.cpp | 16 ++++++++-------- tests/test-db-copy-thread.cpp | 4 ++-- tests/test-properties.cpp | 12 ++++++------ 30 files changed, 114 insertions(+), 101 deletions(-) diff --git a/src/command-line-parser.cpp b/src/command-line-parser.cpp index bc391997b..61bbc5494 100644 --- a/src/command-line-parser.cpp +++ b/src/command-line-parser.cpp @@ -688,7 +688,7 @@ options_t parse_command_line(int argc, char *argv[]) check_options(&options); - options.conninfo = app.connection_params(); + options.connection_params = app.connection_params(); if (!options.slim) { options.middle_database_format = 0; diff --git a/src/db-copy.cpp b/src/db-copy.cpp index 4fd5132f8..3a63a8587 100644 --- a/src/db-copy.cpp +++ b/src/db-copy.cpp @@ -81,12 +81,12 @@ void db_deleter_by_type_and_id_t::delete_rows(std::string const &table, conn->exec(sql.data()); } -db_copy_thread_t::db_copy_thread_t(connection_params_t const &conninfo) +db_copy_thread_t::db_copy_thread_t(connection_params_t const &connection_params) { // Connection params are captured by copy here, because we don't know // whether the reference will still be valid once we get around to running // the thread. - m_worker = std::thread{thread_t{conninfo, &m_shared}}; + m_worker = std::thread{thread_t{connection_params, &m_shared}}; } db_copy_thread_t::~db_copy_thread_t() { finish(); } @@ -120,15 +120,15 @@ void db_copy_thread_t::finish() } } -db_copy_thread_t::thread_t::thread_t(connection_params_t conninfo, +db_copy_thread_t::thread_t::thread_t(connection_params_t connection_params, shared *shared) -: m_conninfo(std::move(conninfo)), m_shared(shared) +: m_connection_params(std::move(connection_params)), m_shared(shared) {} void db_copy_thread_t::thread_t::operator()() { try { - m_conn = std::make_unique(m_conninfo); + m_conn = std::make_unique(m_connection_params); // Let commits happen faster by delaying when they actually occur. m_conn->exec("SET synchronous_commit = off"); diff --git a/src/db-copy.hpp b/src/db-copy.hpp index 58302c97e..5ab4b56fa 100644 --- a/src/db-copy.hpp +++ b/src/db-copy.hpp @@ -249,7 +249,7 @@ struct db_cmd_finish_t : public db_cmd_t class db_copy_thread_t { public: - explicit db_copy_thread_t(connection_params_t const &conninfo); + explicit db_copy_thread_t(connection_params_t const &connection_params); db_copy_thread_t(db_copy_thread_t const &) = delete; db_copy_thread_t &operator=(db_copy_thread_t const &) = delete; @@ -290,7 +290,7 @@ class db_copy_thread_t class thread_t { public: - thread_t(connection_params_t conninfo, shared *shared); + thread_t(connection_params_t connection_params, shared *shared); void operator()(); @@ -300,7 +300,7 @@ class db_copy_thread_t void finish_copy(); void delete_rows(db_cmd_copy_t *buffer); - connection_params_t m_conninfo; + connection_params_t m_connection_params; std::unique_ptr m_conn; // Target for copy operation currently ongoing. diff --git a/src/expire-output.cpp b/src/expire-output.cpp index 911b23a0f..ddcc36931 100644 --- a/src/expire-output.cpp +++ b/src/expire-output.cpp @@ -16,15 +16,16 @@ #include -std::size_t expire_output_t::output(quadkey_list_t const &tile_list, - connection_params_t const &conninfo) const +std::size_t +expire_output_t::output(quadkey_list_t const &tile_list, + connection_params_t const &connection_params) const { std::size_t num = 0; if (!m_filename.empty()) { num = output_tiles_to_file(tile_list); } if (!m_table.empty()) { - num = output_tiles_to_table(tile_list, conninfo); + num = output_tiles_to_table(tile_list, connection_params); } return num; } @@ -53,11 +54,11 @@ std::size_t expire_output_t::output_tiles_to_file( std::size_t expire_output_t::output_tiles_to_table( quadkey_list_t const &tiles_at_maxzoom, - connection_params_t const &conninfo) const + connection_params_t const &connection_params) const { auto const qn = qualified_name(m_schema, m_table); - pg_conn_t connection{conninfo}; + pg_conn_t connection{connection_params}; auto const result = connection.exec("SELECT * FROM {} LIMIT 1", qn); diff --git a/src/expire-output.hpp b/src/expire-output.hpp index 28416b6dd..fc4dba4ad 100644 --- a/src/expire-output.hpp +++ b/src/expire-output.hpp @@ -53,7 +53,7 @@ class expire_output_t void set_maxzoom(uint32_t maxzoom) noexcept { m_maxzoom = maxzoom; } std::size_t output(quadkey_list_t const &tile_list, - connection_params_t const &conninfo) const; + connection_params_t const &connection_params) const; /** * Write the list of tiles to a file. @@ -67,11 +67,11 @@ class expire_output_t * Write the list of tiles to a database table. * * \param tiles_at_maxzoom The list of tiles at maximum zoom level - * \param conninfo Database connection parameters + * \param connection_params Database connection parameters */ std::size_t output_tiles_to_table(quadkey_list_t const &tiles_at_maxzoom, - connection_params_t const &conninfo) const; + connection_params_t const &connection_params) const; /** * Create table for tiles. diff --git a/src/flex-table.cpp b/src/flex-table.cpp index 940e9779f..d9d0111d5 100644 --- a/src/flex-table.cpp +++ b/src/flex-table.cpp @@ -241,11 +241,11 @@ bool flex_table_t::has_columns_with_expire() const noexcept [](auto const &column) { return column.has_expire(); }); } -void table_connection_t::connect(connection_params_t const &conninfo) +void table_connection_t::connect(connection_params_t const &connection_params) { assert(!m_db_connection); - m_db_connection = std::make_unique(conninfo); + m_db_connection = std::make_unique(connection_params); m_db_connection->exec("SET synchronous_commit = off"); } diff --git a/src/flex-table.hpp b/src/flex-table.hpp index bdfe09ccf..efbd71122 100644 --- a/src/flex-table.hpp +++ b/src/flex-table.hpp @@ -259,7 +259,7 @@ class table_connection_t { } - void connect(connection_params_t const &conninfo); + void connect(connection_params_t const &connection_params); void start(bool append); diff --git a/src/gen/osm2pgsql-gen.cpp b/src/gen/osm2pgsql-gen.cpp index d63f9687c..c974c8ffd 100644 --- a/src/gen/osm2pgsql-gen.cpp +++ b/src/gen/osm2pgsql-gen.cpp @@ -195,7 +195,7 @@ class tile_processor_t std::size_t m_num_tiles; }; -void run_tile_gen(connection_params_t const &conninfo, +void run_tile_gen(connection_params_t const &connection_params, gen_base_t *master_generalizer, params_t params, uint32_t zoom, std::vector> *queue, @@ -205,7 +205,7 @@ void run_tile_gen(connection_params_t const &conninfo, log_debug("Started generalizer thread for '{}'.", master_generalizer->strategy()); - pg_conn_t db_connection{conninfo}; + pg_conn_t db_connection{connection_params}; std::string const strategy{master_generalizer->strategy()}; auto generalizer = create_generalizer(strategy, &db_connection, ¶ms); @@ -233,7 +233,7 @@ class genproc_t { public: genproc_t(std::string const &filename, - connection_params_t conninfo, std::string dbschema, + connection_params_t connection_params, std::string dbschema, bool append, bool updatable, uint32_t jobs); int app_define_table() @@ -286,7 +286,7 @@ class genproc_t write_to_debug_log(params, "Params (config):"); log_debug("Connecting to database..."); - pg_conn_t db_connection{m_conninfo}; + pg_conn_t db_connection{m_connection_params}; log_debug("Creating generalizer..."); auto generalizer = @@ -368,7 +368,7 @@ class genproc_t queries.emplace_back("COMMIT"); } - pg_conn_t const db_connection{m_conninfo}; + pg_conn_t const db_connection{m_connection_params}; if (m_append && !if_has_rows.empty()) { auto const result = db_connection.exec(if_has_rows); @@ -496,8 +496,9 @@ class genproc_t for (unsigned int n = 1; n <= std::min(m_jobs, static_cast(tile_list.size())); ++n) { - threads.emplace_back(run_tile_gen, m_conninfo, generalizer, - params, zoom, &tile_list, &mut, n); + threads.emplace_back(run_tile_gen, m_connection_params, + generalizer, params, zoom, &tile_list, + &mut, n); } for (auto &t : threads) { t.join(); @@ -513,7 +514,7 @@ class genproc_t std::vector m_tables; std::vector m_expire_outputs; - connection_params_t m_conninfo; + connection_params_t m_connection_params; std::string m_dbschema; uint32_t m_jobs; bool m_append; @@ -525,11 +526,13 @@ TRAMPOLINE(app_define_expire_output, define_expire_output) TRAMPOLINE(app_run_gen, run_gen) TRAMPOLINE(app_run_sql, run_sql) -genproc_t::genproc_t(std::string const &filename, connection_params_t conninfo, +genproc_t::genproc_t(std::string const &filename, + connection_params_t connection_params, std::string dbschema, bool append, bool updatable, uint32_t jobs) -: m_conninfo(std::move(conninfo)), m_dbschema(std::move(dbschema)), - m_jobs(jobs), m_append(append), m_updatable(updatable) +: m_connection_params(std::move(connection_params)), + m_dbschema(std::move(dbschema)), m_jobs(jobs), m_append(append), + m_updatable(updatable) { setup_lua_environment(lua_state(), filename, append); @@ -589,7 +592,7 @@ void genproc_t::run() } if (!m_append) { - pg_conn_t const db_connection{m_conninfo}; + pg_conn_t const db_connection{m_connection_params}; for (auto const &table : m_tables) { if (table.id_type() == flex_table_index_type::tile && (table.always_build_id_index() || m_updatable)) { diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index bad1595b9..b7ba57b53 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -160,7 +160,7 @@ void middle_pgsql_t::table_desc::drop_table( } void middle_pgsql_t::table_desc::build_index( - connection_params_t const &conninfo) const + connection_params_t const &connection_params) const { if (m_create_fw_dep_indexes.empty()) { return; @@ -168,7 +168,7 @@ void middle_pgsql_t::table_desc::build_index( // Use a temporary connection here because we might run in a separate // thread context. - pg_conn_t const db_connection{conninfo}; + pg_conn_t const db_connection{connection_params}; log_info("Building index on table '{}'", name()); for (auto const &query : m_create_fw_dep_indexes) { @@ -1296,11 +1296,11 @@ void middle_pgsql_t::after_relations() } middle_query_pgsql_t::middle_query_pgsql_t( - connection_params_t const &conninfo, + connection_params_t const &connection_params, std::shared_ptr cache, std::shared_ptr persistent_cache, middle_pgsql_options const &options) -: m_sql_conn(conninfo), m_cache(std::move(cache)), +: m_sql_conn(connection_params), m_cache(std::move(cache)), m_persistent_cache(std::move(persistent_cache)), m_store_options(options) { // Disable JIT and parallel workers as they are known to cause @@ -1409,7 +1409,7 @@ void middle_pgsql_t::stop() // Building the indexes takes time, so do it asynchronously. for (auto &table : m_tables) { table.task_set(thread_pool().submit( - [&]() { table.build_index(m_options->conninfo); })); + [&]() { table.build_index(m_options->connection_params); })); } } } @@ -1649,8 +1649,8 @@ middle_pgsql_t::middle_pgsql_t(std::shared_ptr thread_pool, : middle_t(std::move(thread_pool)), m_options(options), m_cache(std::make_unique( static_cast(options->cache) * 1024UL * 1024UL)), - m_db_connection(m_options->conninfo), - m_copy_thread(std::make_shared(options->conninfo)), + m_db_connection(m_options->connection_params), + m_copy_thread(std::make_shared(options->connection_params)), m_db_copy(m_copy_thread), m_append(options->append) { m_store_options.with_attributes = options->extra_attributes; @@ -1725,7 +1725,8 @@ middle_pgsql_t::get_query_instance() // NOTE: this is thread safe for use in pending async processing only // because during that process they are only read from auto mid = std::make_unique( - m_options->conninfo, m_cache, m_persistent_cache, m_store_options); + m_options->connection_params, m_cache, m_persistent_cache, + m_store_options); // We use a connection per table to enable the use of COPY for (auto &table : m_tables) { diff --git a/src/middle-pgsql.hpp b/src/middle-pgsql.hpp index b67183818..34403272b 100644 --- a/src/middle-pgsql.hpp +++ b/src/middle-pgsql.hpp @@ -55,7 +55,7 @@ class middle_query_pgsql_t : public middle_query_t { public: middle_query_pgsql_t( - connection_params_t const &conninfo, + connection_params_t const &connection_params, std::shared_ptr cache, std::shared_ptr persistent_cache, middle_pgsql_options const &options); @@ -151,7 +151,7 @@ struct middle_pgsql_t : public middle_t void drop_table(pg_conn_t const &db_connection) const; ///< Open a new database connection and build index on this table. - void build_index(connection_params_t const &conninfo) const; + void build_index(connection_params_t const &connection_params) const; std::string m_create_table; std::vector m_prepare_queries; diff --git a/src/options.hpp b/src/options.hpp index 996e889d8..458927d95 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -47,7 +47,7 @@ struct options_t command_t command = command_t::process; /// Parameters for initializing database connections - connection_params_t conninfo; + connection_params_t connection_params; std::string prefix{"planet_osm"}; ///< prefix for table names bool prefix_is_set = false; diff --git a/src/osm2pgsql.cpp b/src/osm2pgsql.cpp index 46e0c57d8..209c98f52 100644 --- a/src/osm2pgsql.cpp +++ b/src/osm2pgsql.cpp @@ -86,7 +86,7 @@ static file_info run(options_t const &options) static void check_db(options_t const &options) { - pg_conn_t const db_connection{options.conninfo}; + pg_conn_t const db_connection{options.connection_params}; init_database_capabilities(db_connection); @@ -372,7 +372,8 @@ int main(int argc, char *argv[]) check_db(options); - properties_t properties{options.conninfo, options.middle_dbschema}; + properties_t properties{options.connection_params, + options.middle_dbschema}; if (options.append) { if (properties.load()) { check_and_update_properties(&properties, &options); diff --git a/src/osmdata.cpp b/src/osmdata.cpp index 6ddb261ef..0779a6c8b 100644 --- a/src/osmdata.cpp +++ b/src/osmdata.cpp @@ -30,7 +30,7 @@ osmdata_t::osmdata_t(std::unique_ptr dependency_manager, std::shared_ptr mid, std::shared_ptr output, options_t const &options) : m_dependency_manager(std::move(dependency_manager)), m_mid(std::move(mid)), - m_output(std::move(output)), m_conninfo(options.conninfo), + m_output(std::move(output)), m_connection_params(options.connection_params), m_bbox(options.bbox), m_num_procs(options.num_procs), m_append(options.append), m_droptemp(options.droptemp), m_with_extra_attrs(options.extra_attributes), @@ -171,7 +171,7 @@ namespace { class multithreaded_processor { public: - multithreaded_processor(connection_params_t const &conninfo, + multithreaded_processor(connection_params_t const &connection_params, std::shared_ptr const &mid, std::shared_ptr output, std::size_t thread_count) @@ -183,7 +183,8 @@ class multithreaded_processor // For each thread we create a clone of the output. for (std::size_t i = 0; i < thread_count; ++i) { auto const midq = mid->get_query_instance(); - auto copy_thread = std::make_shared(conninfo); + auto copy_thread = + std::make_shared(connection_params); m_clones.push_back(m_output->clone(midq, copy_thread)); } } @@ -350,7 +351,8 @@ class multithreaded_processor void osmdata_t::process_dependents() const { - multithreaded_processor proc{m_conninfo, m_mid, m_output, m_num_procs}; + multithreaded_processor proc{m_connection_params, m_mid, m_output, + m_num_procs}; // stage 1b processing: process parents of changed objects if (m_dependency_manager->has_pending()) { diff --git a/src/osmdata.hpp b/src/osmdata.hpp index 8492ec812..78b6ddee1 100644 --- a/src/osmdata.hpp +++ b/src/osmdata.hpp @@ -80,7 +80,7 @@ class osmdata_t : public osmium::handler::Handler std::shared_ptr m_mid; std::shared_ptr m_output; - connection_params_t m_conninfo; + connection_params_t m_connection_params; // Bounding box for node import (or invalid Box if everything should be // imported). diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 1bcddcc7d..7ead87e24 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -1086,8 +1086,9 @@ void output_flex_t::stop() if (!m_expire_tiles[i].empty()) { auto const &eo = (*m_expire_outputs)[i]; - std::size_t const count = eo.output(m_expire_tiles[i].get_tiles(), - get_options()->conninfo); + std::size_t const count = + eo.output(m_expire_tiles[i].get_tiles(), + get_options()->connection_params); log_info("Wrote {} entries to expire output [{}].", count, i); } @@ -1224,14 +1225,14 @@ void output_flex_t::relation_modify(osmium::Relation const &rel) void output_flex_t::start() { for (auto &table : m_table_connections) { - table.connect(get_options()->conninfo); + table.connect(get_options()->connection_params); table.start(get_options()->append); } } static void create_expire_tables(std::vector const &expire_outputs, - connection_params_t const &conninfo) + connection_params_t const &connection_params) { if (std::all_of(expire_outputs.begin(), expire_outputs.end(), [](auto const &expire_output) { @@ -1240,7 +1241,7 @@ create_expire_tables(std::vector const &expire_outputs, return; } - pg_conn_t const connection{conninfo}; + pg_conn_t const connection{connection_params}; for (auto const &expire_output : expire_outputs) { if (!expire_output.table().empty()) { expire_output.create_output_table(connection); @@ -1261,7 +1262,7 @@ output_flex_t::output_flex_t(output_flex_t const *other, { for (auto &table : *m_tables) { auto &tc = m_table_connections.emplace_back(&table, m_copy_thread); - tc.connect(get_options()->conninfo); + tc.connect(get_options()->connection_params); tc.prepare(); } @@ -1282,7 +1283,7 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, std::shared_ptr thread_pool, options_t const &options) : output_t(mid, std::move(thread_pool), options), - m_copy_thread(std::make_shared(options.conninfo)) + m_copy_thread(std::make_shared(options.connection_params)) { init_lua(options.style); @@ -1331,7 +1332,7 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, reprojection::create_projection(3857)); } - create_expire_tables(*m_expire_outputs, get_options()->conninfo); + create_expire_tables(*m_expire_outputs, get_options()->connection_params); } /** diff --git a/src/output-gazetteer.cpp b/src/output-gazetteer.cpp index 044bbbdbe..da41974f5 100644 --- a/src/output-gazetteer.cpp +++ b/src/output-gazetteer.cpp @@ -49,7 +49,7 @@ void output_gazetteer_t::start() if (!get_options()->append) { int const srid = get_options()->projection->target_srs(); - pg_conn_t const conn{get_options()->conninfo}; + pg_conn_t const conn{get_options()->connection_params}; /* Drop any existing table */ conn.exec("DROP TABLE IF EXISTS place CASCADE"); diff --git a/src/output-gazetteer.hpp b/src/output-gazetteer.hpp index 0f75a6a6b..6f427d6be 100644 --- a/src/output-gazetteer.hpp +++ b/src/output-gazetteer.hpp @@ -35,7 +35,7 @@ class output_gazetteer_t : public output_t std::shared_ptr thread_pool, options_t const &options) : output_t(mid, std::move(thread_pool), options), - m_copy(std::make_shared(options.conninfo)), + m_copy(std::make_shared(options.connection_params)), m_proj(options.projection) { m_style.load_style(options.style); diff --git a/src/output-pgsql.cpp b/src/output-pgsql.cpp index 40fa608db..9f2fc621d 100644 --- a/src/output-pgsql.cpp +++ b/src/output-pgsql.cpp @@ -418,7 +418,8 @@ void output_pgsql_t::start() { for (auto &t : m_tables) { //setup the table in postgres - t->start(get_options()->conninfo, get_options()->tblsmain_data); + t->start(get_options()->connection_params, + get_options()->tblsmain_data); } } @@ -451,7 +452,8 @@ output_pgsql_t::output_pgsql_t(std::shared_ptr const &mid, m_tagtransform = tagtransform_t::make_tagtransform(&options, exlist); - auto copy_thread = std::make_shared(options.conninfo); + auto copy_thread = + std::make_shared(options.connection_params); //for each table for (std::size_t i = 0; i < m_tables.size(); ++i) { diff --git a/src/pgsql.cpp b/src/pgsql.cpp index 031caf012..617470621 100644 --- a/src/pgsql.cpp +++ b/src/pgsql.cpp @@ -49,10 +49,10 @@ static PGconn *open_connection(connection_params_t const &connection_params, return PQconnectdbParams(keywords.data(), values.data(), 1); } -pg_conn_t::pg_conn_t(connection_params_t const &conninfo) +pg_conn_t::pg_conn_t(connection_params_t const &connection_params) : m_connection_id(connection_id.fetch_add(1)) { - m_conn.reset(open_connection(conninfo, m_connection_id)); + m_conn.reset(open_connection(connection_params, m_connection_id)); if (!m_conn) { throw std::runtime_error{"Connecting to database failed."}; diff --git a/src/pgsql.hpp b/src/pgsql.hpp index 38b9dd445..4774602a8 100644 --- a/src/pgsql.hpp +++ b/src/pgsql.hpp @@ -152,7 +152,7 @@ class binary_param : public std::string_view class pg_conn_t { public: - explicit pg_conn_t(connection_params_t const &conninfo); + explicit pg_conn_t(connection_params_t const &connection_params); /** * Run the specified SQL command. diff --git a/src/properties.cpp b/src/properties.cpp index 09fbb58af..393b95db3 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -19,8 +19,10 @@ static constexpr char const *const properties_table = "osm2pgsql_properties"; -properties_t::properties_t(connection_params_t conninfo, std::string schema) -: m_conninfo(std::move(conninfo)), m_schema(std::move(schema)), +properties_t::properties_t(connection_params_t connection_params, + std::string schema) +: m_connection_params(std::move(connection_params)), + m_schema(std::move(schema)), m_has_properties_table(has_table(m_schema, properties_table)) { assert(!m_schema.empty()); @@ -90,7 +92,7 @@ void properties_t::set_string(std::string property, std::string value, auto const &inserted = *(r.first); log_debug(" Storing {}='{}'", inserted.first, inserted.second); - pg_conn_t const db_connection{m_conninfo}; + pg_conn_t const db_connection{m_connection_params}; db_connection.exec( "PREPARE set_property(text, text) AS" " INSERT INTO {} (property, value) VALUES ($1, $2)" @@ -117,7 +119,7 @@ void properties_t::store() auto const table = table_name(); log_info("Storing properties to table '{}'.", table); - pg_conn_t const db_connection{m_conninfo}; + pg_conn_t const db_connection{m_connection_params}; if (m_has_properties_table) { db_connection.exec("TRUNCATE {}", table); @@ -151,7 +153,7 @@ bool properties_t::load() auto const table = table_name(); log_info("Loading properties from table '{}'.", table); - pg_conn_t const db_connection{m_conninfo}; + pg_conn_t const db_connection{m_connection_params}; auto const result = db_connection.exec("SELECT * FROM {}", table); for (int i = 0; i < result.num_tuples(); ++i) { diff --git a/src/properties.hpp b/src/properties.hpp index 3e2339478..f8339da9f 100644 --- a/src/properties.hpp +++ b/src/properties.hpp @@ -32,12 +32,12 @@ class properties_t /** * Create new properties store. * - * \param conninfo Parameters used to connect to the database. + * \param connection_params Parameters used to connect to the database. * \param schema The schema used for storing the data, * * \pre You must have called init_database_capabilities() before this. */ - properties_t(connection_params_t conninfo, std::string schema); + properties_t(connection_params_t connection_params, std::string schema); std::string get_string(std::string const &property, std::string const &default_value) const; @@ -97,7 +97,7 @@ class properties_t std::string table_name() const; std::map m_properties; - connection_params_t m_conninfo; + connection_params_t m_connection_params; std::string m_schema; bool m_has_properties_table; diff --git a/src/table.cpp b/src/table.cpp index 9875a125f..f0d021180 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -45,8 +45,8 @@ table_t::table_t(std::string const &name, std::string type, columns_t columns, table_t::table_t(table_t const &other, std::shared_ptr const ©_thread) -: m_conninfo(other.m_conninfo), m_target(other.m_target), m_type(other.m_type), - m_srid(other.m_srid), m_append(other.m_append), +: m_connection_params(other.m_connection_params), m_target(other.m_target), + m_type(other.m_type), m_srid(other.m_srid), m_append(other.m_append), m_hstore_mode(other.m_hstore_mode), m_columns(other.m_columns), m_hstore_columns(other.m_hstore_columns), m_table_space(other.m_table_space), m_copy(copy_thread) @@ -66,12 +66,12 @@ void table_t::sync() { m_copy.sync(); } void table_t::connect() { - m_sql_conn = std::make_unique(m_conninfo); + m_sql_conn = std::make_unique(m_connection_params); //let commits happen faster by delaying when they actually occur m_sql_conn->exec("SET synchronous_commit = off"); } -void table_t::start(connection_params_t const &conninfo, +void table_t::start(connection_params_t const &connection_params, std::string const &table_space) { if (m_sql_conn) { @@ -79,7 +79,7 @@ void table_t::start(connection_params_t const &conninfo, m_target->name()); } - m_conninfo = conninfo; + m_connection_params = connection_params; m_table_space = tablespace_clause(table_space); connect(); diff --git a/src/table.hpp b/src/table.hpp index ca97ba073..3cfb8ab4a 100644 --- a/src/table.hpp +++ b/src/table.hpp @@ -37,7 +37,7 @@ class table_t table_t(table_t const &other, std::shared_ptr const ©_thread); - void start(connection_params_t const &conninfo, + void start(connection_params_t const &connection_params, std::string const &table_space); void stop(bool updateable, bool enable_hstore_index, std::string const &table_space_index); @@ -70,7 +70,7 @@ class table_t void generate_copy_column_list(); - connection_params_t m_conninfo; + connection_params_t m_connection_params; std::shared_ptr m_target; std::string m_type; std::unique_ptr m_sql_conn; diff --git a/tests/common-import.hpp b/tests/common-import.hpp index 35abc1651..9fc7bb325 100644 --- a/tests/common-import.hpp +++ b/tests/common-import.hpp @@ -134,7 +134,7 @@ class import_t std::initializer_list input_data, std::string const &format = "opl") { - options.conninfo = m_db.conninfo(); + options.connection_params = m_db.connection_params(); auto thread_pool = std::make_shared(1U); auto middle = create_middle(thread_pool, options); @@ -173,7 +173,7 @@ class import_t void run_file(options_t options, char const *file = nullptr) { - options.conninfo = m_db.conninfo(); + options.connection_params = m_db.connection_params(); auto thread_pool = std::make_shared(1U); auto middle = std::make_shared(thread_pool, &options); diff --git a/tests/common-options.hpp b/tests/common-options.hpp index 5a4582eaa..446289a62 100644 --- a/tests/common-options.hpp +++ b/tests/common-options.hpp @@ -44,7 +44,7 @@ class opt_t opt_t &slim(testing::pg::tempdb_t const &db) { m_opt.slim = true; - m_opt.conninfo = db.conninfo(); + m_opt.connection_params = db.connection_params(); return *this; } diff --git a/tests/common-pg.hpp b/tests/common-pg.hpp index 6af7d58bc..2113fd23f 100644 --- a/tests/common-pg.hpp +++ b/tests/common-pg.hpp @@ -153,9 +153,9 @@ class tempdb_t } } - conn_t connect() const { return conn_t{conninfo()}; } + conn_t connect() const { return conn_t{connection_params()}; } - connection_params_t conninfo() const { + connection_params_t connection_params() const { connection_params_t params; params.set("dbname", m_db_name); return params; diff --git a/tests/test-db-copy-mgr.cpp b/tests/test-db-copy-mgr.cpp index 2aec343af..ef9df4bfc 100644 --- a/tests/test-db-copy-mgr.cpp +++ b/tests/test-db-copy-mgr.cpp @@ -89,7 +89,7 @@ static void check_row(std::vector const &row) TEST_CASE("copy_mgr_t: Insert null") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("big int8, t text"); @@ -109,7 +109,7 @@ TEST_CASE("copy_mgr_t: Insert null") TEST_CASE("copy_mgr_t: Insert numbers") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("big int8, small smallint"); @@ -119,7 +119,7 @@ TEST_CASE("copy_mgr_t: Insert numbers") TEST_CASE("copy_mgr_t: Insert strings") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("s0 text, s1 varchar"); @@ -150,7 +150,7 @@ TEST_CASE("copy_mgr_t: Insert strings") TEST_CASE("copy_mgr_t: Insert int arrays") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("a int[]"); @@ -160,7 +160,7 @@ TEST_CASE("copy_mgr_t: Insert int arrays") TEST_CASE("copy_mgr_t: Insert string arrays") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("a text[]"); @@ -183,7 +183,7 @@ TEST_CASE("copy_mgr_t: Insert string arrays") TEST_CASE("copy_mgr_t: Insert hashes") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("h hstore"); @@ -206,7 +206,7 @@ TEST_CASE("copy_mgr_t: Insert hashes") TEST_CASE("copy_mgr_t: Insert something and roll back") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("t text"); @@ -223,7 +223,7 @@ TEST_CASE("copy_mgr_t: Insert something and roll back") TEST_CASE("copy_mgr_t: Insert something, insert more, roll back, insert " "something else") { - copy_mgr_t mgr{std::make_shared(db.conninfo())}; + copy_mgr_t mgr{std::make_shared(db.connection_params())}; auto const t = setup_table("t text"); diff --git a/tests/test-db-copy-thread.cpp b/tests/test-db-copy-thread.cpp index 2932817f2..9cfd30c61 100644 --- a/tests/test-db-copy-thread.cpp +++ b/tests/test-db-copy-thread.cpp @@ -30,7 +30,7 @@ TEST_CASE("db_copy_thread_t with db_deleter_by_id_t") auto const table = std::make_shared("public", "test_copy_thread", "id"); - db_copy_thread_t t(db.conninfo()); + db_copy_thread_t t{db.connection_params()}; using cmd_copy_t = db_cmd_copy_delete_t; auto cmd = std::make_unique(table); @@ -159,7 +159,7 @@ TEST_CASE("db_copy_thread_t with db_deleter_place_t") auto table = std::make_shared( "public", "test_copy_thread", "place_id"); - db_copy_thread_t t(db.conninfo()); + db_copy_thread_t t{db.connection_params()}; using cmd_copy_t = db_cmd_copy_delete_t; auto cmd = std::make_unique(table); diff --git a/tests/test-properties.cpp b/tests/test-properties.cpp index 0d925c124..1e1aa5b91 100644 --- a/tests/test-properties.cpp +++ b/tests/test-properties.cpp @@ -52,7 +52,7 @@ TEST_CASE("Store and retrieve properties (with database)") } { - properties_t properties{db.conninfo(), schema}; + properties_t properties{db.connection_params(), schema}; properties.set_string("foo", "bar"); properties.set_string("empty", ""); @@ -77,7 +77,7 @@ TEST_CASE("Store and retrieve properties (with database)") REQUIRE(conn.get_count(full_table_name, "property='decide' AND value='true'") == 1); - properties_t properties{db.conninfo(), schema}; + properties_t properties{db.connection_params(), schema}; REQUIRE(properties.load()); REQUIRE(properties.get_string("foo", "baz") == "bar"); @@ -106,7 +106,7 @@ TEST_CASE("Update existing properties in database") auto conn = db.connect(); { - properties_t properties{db.conninfo(), "public"}; + properties_t properties{db.connection_params(), "public"}; properties.set_string("a", "xxx"); properties.set_string("b", "yyy"); @@ -118,7 +118,7 @@ TEST_CASE("Update existing properties in database") init_database_capabilities(conn); REQUIRE(conn.get_count("osm2pgsql_properties") == 2); - properties_t properties{db.conninfo(), "public"}; + properties_t properties{db.connection_params(), "public"}; REQUIRE(properties.load()); REQUIRE(properties.get_string("a", "def") == "xxx"); @@ -135,7 +135,7 @@ TEST_CASE("Update existing properties in database") { REQUIRE(conn.get_count("osm2pgsql_properties") == 2); - properties_t properties{db.conninfo(), "public"}; + properties_t properties{db.connection_params(), "public"}; REQUIRE(properties.load()); // only "b" was updated in the database @@ -150,6 +150,6 @@ TEST_CASE("Load returns false if there are no properties in database") auto conn = db.connect(); init_database_capabilities(conn); - properties_t properties{db.conninfo(), "public"}; + properties_t properties{db.connection_params(), "public"}; REQUIRE_FALSE(properties.load()); }