Skip to content

Commit abd6554

Browse files
committed
Rename conninfo to connection_params everywhere
This is really part of the previous commit but was factored out to keep that one reasonably legible.
1 parent 46ef18e commit abd6554

30 files changed

+114
-101
lines changed

src/command-line-parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ options_t parse_command_line(int argc, char *argv[])
688688

689689
check_options(&options);
690690

691-
options.conninfo = app.connection_params();
691+
options.connection_params = app.connection_params();
692692

693693
if (!options.slim) {
694694
options.middle_database_format = 0;

src/db-copy.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ void db_deleter_by_type_and_id_t::delete_rows(std::string const &table,
8181
conn->exec(sql.data());
8282
}
8383

84-
db_copy_thread_t::db_copy_thread_t(connection_params_t const &conninfo)
84+
db_copy_thread_t::db_copy_thread_t(connection_params_t const &connection_params)
8585
{
8686
// Connection params are captured by copy here, because we don't know
8787
// whether the reference will still be valid once we get around to running
8888
// the thread.
89-
m_worker = std::thread{thread_t{conninfo, &m_shared}};
89+
m_worker = std::thread{thread_t{connection_params, &m_shared}};
9090
}
9191

9292
db_copy_thread_t::~db_copy_thread_t() { finish(); }
@@ -120,15 +120,15 @@ void db_copy_thread_t::finish()
120120
}
121121
}
122122

123-
db_copy_thread_t::thread_t::thread_t(connection_params_t conninfo,
123+
db_copy_thread_t::thread_t::thread_t(connection_params_t connection_params,
124124
shared *shared)
125-
: m_conninfo(std::move(conninfo)), m_shared(shared)
125+
: m_connection_params(std::move(connection_params)), m_shared(shared)
126126
{}
127127

128128
void db_copy_thread_t::thread_t::operator()()
129129
{
130130
try {
131-
m_conn = std::make_unique<pg_conn_t>(m_conninfo);
131+
m_conn = std::make_unique<pg_conn_t>(m_connection_params);
132132

133133
// Let commits happen faster by delaying when they actually occur.
134134
m_conn->exec("SET synchronous_commit = off");

src/db-copy.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ struct db_cmd_finish_t : public db_cmd_t
249249
class db_copy_thread_t
250250
{
251251
public:
252-
explicit db_copy_thread_t(connection_params_t const &conninfo);
252+
explicit db_copy_thread_t(connection_params_t const &connection_params);
253253

254254
db_copy_thread_t(db_copy_thread_t const &) = delete;
255255
db_copy_thread_t &operator=(db_copy_thread_t const &) = delete;
@@ -290,7 +290,7 @@ class db_copy_thread_t
290290
class thread_t
291291
{
292292
public:
293-
thread_t(connection_params_t conninfo, shared *shared);
293+
thread_t(connection_params_t connection_params, shared *shared);
294294

295295
void operator()();
296296

@@ -300,7 +300,7 @@ class db_copy_thread_t
300300
void finish_copy();
301301
void delete_rows(db_cmd_copy_t *buffer);
302302

303-
connection_params_t m_conninfo;
303+
connection_params_t m_connection_params;
304304
std::unique_ptr<pg_conn_t> m_conn;
305305

306306
// Target for copy operation currently ongoing.

src/expire-output.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616

1717
#include <system_error>
1818

19-
std::size_t expire_output_t::output(quadkey_list_t const &tile_list,
20-
connection_params_t const &conninfo) const
19+
std::size_t
20+
expire_output_t::output(quadkey_list_t const &tile_list,
21+
connection_params_t const &connection_params) const
2122
{
2223
std::size_t num = 0;
2324
if (!m_filename.empty()) {
2425
num = output_tiles_to_file(tile_list);
2526
}
2627
if (!m_table.empty()) {
27-
num = output_tiles_to_table(tile_list, conninfo);
28+
num = output_tiles_to_table(tile_list, connection_params);
2829
}
2930
return num;
3031
}
@@ -53,11 +54,11 @@ std::size_t expire_output_t::output_tiles_to_file(
5354

5455
std::size_t expire_output_t::output_tiles_to_table(
5556
quadkey_list_t const &tiles_at_maxzoom,
56-
connection_params_t const &conninfo) const
57+
connection_params_t const &connection_params) const
5758
{
5859
auto const qn = qualified_name(m_schema, m_table);
5960

60-
pg_conn_t connection{conninfo};
61+
pg_conn_t connection{connection_params};
6162

6263
auto const result = connection.exec("SELECT * FROM {} LIMIT 1", qn);
6364

src/expire-output.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class expire_output_t
5353
void set_maxzoom(uint32_t maxzoom) noexcept { m_maxzoom = maxzoom; }
5454

5555
std::size_t output(quadkey_list_t const &tile_list,
56-
connection_params_t const &conninfo) const;
56+
connection_params_t const &connection_params) const;
5757

5858
/**
5959
* Write the list of tiles to a file.
@@ -67,11 +67,11 @@ class expire_output_t
6767
* Write the list of tiles to a database table.
6868
*
6969
* \param tiles_at_maxzoom The list of tiles at maximum zoom level
70-
* \param conninfo Database connection parameters
70+
* \param connection_params Database connection parameters
7171
*/
7272
std::size_t
7373
output_tiles_to_table(quadkey_list_t const &tiles_at_maxzoom,
74-
connection_params_t const &conninfo) const;
74+
connection_params_t const &connection_params) const;
7575

7676
/**
7777
* Create table for tiles.

src/flex-table.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ bool flex_table_t::has_columns_with_expire() const noexcept
241241
[](auto const &column) { return column.has_expire(); });
242242
}
243243

244-
void table_connection_t::connect(connection_params_t const &conninfo)
244+
void table_connection_t::connect(connection_params_t const &connection_params)
245245
{
246246
assert(!m_db_connection);
247247

248-
m_db_connection = std::make_unique<pg_conn_t>(conninfo);
248+
m_db_connection = std::make_unique<pg_conn_t>(connection_params);
249249
m_db_connection->exec("SET synchronous_commit = off");
250250
}
251251

src/flex-table.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class table_connection_t
259259
{
260260
}
261261

262-
void connect(connection_params_t const &conninfo);
262+
void connect(connection_params_t const &connection_params);
263263

264264
void start(bool append);
265265

src/gen/osm2pgsql-gen.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class tile_processor_t
195195
std::size_t m_num_tiles;
196196
};
197197

198-
void run_tile_gen(connection_params_t const &conninfo,
198+
void run_tile_gen(connection_params_t const &connection_params,
199199
gen_base_t *master_generalizer, params_t params,
200200
uint32_t zoom,
201201
std::vector<std::pair<uint32_t, uint32_t>> *queue,
@@ -205,7 +205,7 @@ void run_tile_gen(connection_params_t const &conninfo,
205205

206206
log_debug("Started generalizer thread for '{}'.",
207207
master_generalizer->strategy());
208-
pg_conn_t db_connection{conninfo};
208+
pg_conn_t db_connection{connection_params};
209209
std::string const strategy{master_generalizer->strategy()};
210210
auto generalizer = create_generalizer(strategy, &db_connection, &params);
211211

@@ -233,7 +233,7 @@ class genproc_t
233233
{
234234
public:
235235
genproc_t(std::string const &filename,
236-
connection_params_t conninfo, std::string dbschema,
236+
connection_params_t connection_params, std::string dbschema,
237237
bool append, bool updatable, uint32_t jobs);
238238

239239
int app_define_table()
@@ -286,7 +286,7 @@ class genproc_t
286286
write_to_debug_log(params, "Params (config):");
287287

288288
log_debug("Connecting to database...");
289-
pg_conn_t db_connection{m_conninfo};
289+
pg_conn_t db_connection{m_connection_params};
290290

291291
log_debug("Creating generalizer...");
292292
auto generalizer =
@@ -368,7 +368,7 @@ class genproc_t
368368
queries.emplace_back("COMMIT");
369369
}
370370

371-
pg_conn_t const db_connection{m_conninfo};
371+
pg_conn_t const db_connection{m_connection_params};
372372

373373
if (m_append && !if_has_rows.empty()) {
374374
auto const result = db_connection.exec(if_has_rows);
@@ -496,8 +496,9 @@ class genproc_t
496496
for (unsigned int n = 1;
497497
n <= std::min(m_jobs, static_cast<uint32_t>(tile_list.size()));
498498
++n) {
499-
threads.emplace_back(run_tile_gen, m_conninfo, generalizer,
500-
params, zoom, &tile_list, &mut, n);
499+
threads.emplace_back(run_tile_gen, m_connection_params,
500+
generalizer, params, zoom, &tile_list,
501+
&mut, n);
501502
}
502503
for (auto &t : threads) {
503504
t.join();
@@ -513,7 +514,7 @@ class genproc_t
513514
std::vector<flex_table_t> m_tables;
514515
std::vector<expire_output_t> m_expire_outputs;
515516

516-
connection_params_t m_conninfo;
517+
connection_params_t m_connection_params;
517518
std::string m_dbschema;
518519
uint32_t m_jobs;
519520
bool m_append;
@@ -525,11 +526,13 @@ TRAMPOLINE(app_define_expire_output, define_expire_output)
525526
TRAMPOLINE(app_run_gen, run_gen)
526527
TRAMPOLINE(app_run_sql, run_sql)
527528

528-
genproc_t::genproc_t(std::string const &filename, connection_params_t conninfo,
529+
genproc_t::genproc_t(std::string const &filename,
530+
connection_params_t connection_params,
529531
std::string dbschema, bool append, bool updatable,
530532
uint32_t jobs)
531-
: m_conninfo(std::move(conninfo)), m_dbschema(std::move(dbschema)),
532-
m_jobs(jobs), m_append(append), m_updatable(updatable)
533+
: m_connection_params(std::move(connection_params)),
534+
m_dbschema(std::move(dbschema)), m_jobs(jobs), m_append(append),
535+
m_updatable(updatable)
533536
{
534537
setup_lua_environment(lua_state(), filename, append);
535538

@@ -589,7 +592,7 @@ void genproc_t::run()
589592
}
590593

591594
if (!m_append) {
592-
pg_conn_t const db_connection{m_conninfo};
595+
pg_conn_t const db_connection{m_connection_params};
593596
for (auto const &table : m_tables) {
594597
if (table.id_type() == flex_table_index_type::tile &&
595598
(table.always_build_id_index() || m_updatable)) {

src/middle-pgsql.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ void middle_pgsql_t::table_desc::drop_table(
160160
}
161161

162162
void middle_pgsql_t::table_desc::build_index(
163-
connection_params_t const &conninfo) const
163+
connection_params_t const &connection_params) const
164164
{
165165
if (m_create_fw_dep_indexes.empty()) {
166166
return;
167167
}
168168

169169
// Use a temporary connection here because we might run in a separate
170170
// thread context.
171-
pg_conn_t const db_connection{conninfo};
171+
pg_conn_t const db_connection{connection_params};
172172

173173
log_info("Building index on table '{}'", name());
174174
for (auto const &query : m_create_fw_dep_indexes) {
@@ -1296,11 +1296,11 @@ void middle_pgsql_t::after_relations()
12961296
}
12971297

12981298
middle_query_pgsql_t::middle_query_pgsql_t(
1299-
connection_params_t const &conninfo,
1299+
connection_params_t const &connection_params,
13001300
std::shared_ptr<node_locations_t> cache,
13011301
std::shared_ptr<node_persistent_cache> persistent_cache,
13021302
middle_pgsql_options const &options)
1303-
: m_sql_conn(conninfo), m_cache(std::move(cache)),
1303+
: m_sql_conn(connection_params), m_cache(std::move(cache)),
13041304
m_persistent_cache(std::move(persistent_cache)), m_store_options(options)
13051305
{
13061306
// Disable JIT and parallel workers as they are known to cause
@@ -1409,7 +1409,7 @@ void middle_pgsql_t::stop()
14091409
// Building the indexes takes time, so do it asynchronously.
14101410
for (auto &table : m_tables) {
14111411
table.task_set(thread_pool().submit(
1412-
[&]() { table.build_index(m_options->conninfo); }));
1412+
[&]() { table.build_index(m_options->connection_params); }));
14131413
}
14141414
}
14151415
}
@@ -1649,8 +1649,8 @@ middle_pgsql_t::middle_pgsql_t(std::shared_ptr<thread_pool_t> thread_pool,
16491649
: middle_t(std::move(thread_pool)), m_options(options),
16501650
m_cache(std::make_unique<node_locations_t>(
16511651
static_cast<std::size_t>(options->cache) * 1024UL * 1024UL)),
1652-
m_db_connection(m_options->conninfo),
1653-
m_copy_thread(std::make_shared<db_copy_thread_t>(options->conninfo)),
1652+
m_db_connection(m_options->connection_params),
1653+
m_copy_thread(std::make_shared<db_copy_thread_t>(options->connection_params)),
16541654
m_db_copy(m_copy_thread), m_append(options->append)
16551655
{
16561656
m_store_options.with_attributes = options->extra_attributes;
@@ -1725,7 +1725,8 @@ middle_pgsql_t::get_query_instance()
17251725
// NOTE: this is thread safe for use in pending async processing only
17261726
// because during that process they are only read from
17271727
auto mid = std::make_unique<middle_query_pgsql_t>(
1728-
m_options->conninfo, m_cache, m_persistent_cache, m_store_options);
1728+
m_options->connection_params, m_cache, m_persistent_cache,
1729+
m_store_options);
17291730

17301731
// We use a connection per table to enable the use of COPY
17311732
for (auto &table : m_tables) {

src/middle-pgsql.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class middle_query_pgsql_t : public middle_query_t
5555
{
5656
public:
5757
middle_query_pgsql_t(
58-
connection_params_t const &conninfo,
58+
connection_params_t const &connection_params,
5959
std::shared_ptr<node_locations_t> cache,
6060
std::shared_ptr<node_persistent_cache> persistent_cache,
6161
middle_pgsql_options const &options);
@@ -151,7 +151,7 @@ struct middle_pgsql_t : public middle_t
151151
void drop_table(pg_conn_t const &db_connection) const;
152152

153153
///< Open a new database connection and build index on this table.
154-
void build_index(connection_params_t const &conninfo) const;
154+
void build_index(connection_params_t const &connection_params) const;
155155

156156
std::string m_create_table;
157157
std::vector<std::string> m_prepare_queries;

0 commit comments

Comments
 (0)