Skip to content

Commit 0343ae8

Browse files
committed
Consistently use name m_db_connection in db-copy
Instead of using m_conn.
1 parent efb11cb commit 0343ae8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/db-copy.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ db_copy_thread_t::thread_t::thread_t(connection_params_t connection_params,
128128
void db_copy_thread_t::thread_t::operator()()
129129
{
130130
try {
131-
m_conn = std::make_unique<pg_conn_t>(m_connection_params, "copy");
131+
m_db_connection =
132+
std::make_unique<pg_conn_t>(m_connection_params, "copy");
132133

133134
// Disable sequential scan on database tables in the copy threads.
134135
// The copy threads only do COPYs (which are unaffected by this
135136
// setting) and DELETEs which we know benefit from the index. For
136137
// some reason PostgreSQL chooses in some cases not to use that index,
137138
// possibly because the DELETEs get a large list of ids to delete of
138139
// which many are not in the table which confuses the query planner.
139-
m_conn->exec("SET enable_seqscan = off");
140+
m_db_connection->exec("SET enable_seqscan = off");
140141

141142
bool done = false;
142143
while (!done) {
@@ -167,7 +168,7 @@ void db_copy_thread_t::thread_t::operator()()
167168

168169
finish_copy();
169170

170-
m_conn.reset();
171+
m_db_connection.reset();
171172
} catch (std::runtime_error const &e) {
172173
log_error("DB copy thread failed: {}", e.what());
173174
std::exit(2); // NOLINT(concurrency-mt-unsafe)
@@ -181,13 +182,13 @@ void db_copy_thread_t::thread_t::write_to_db(db_cmd_copy_t *buffer)
181182
finish_copy();
182183
}
183184

184-
buffer->delete_data(m_conn.get());
185+
buffer->delete_data(m_db_connection.get());
185186

186187
if (!m_inflight) {
187188
start_copy(buffer->target);
188189
}
189190

190-
m_conn->copy_send(buffer->buffer, buffer->target->name());
191+
m_db_connection->copy_send(buffer->buffer, buffer->target->name());
191192
}
192193

193194
void db_copy_thread_t::thread_t::start_copy(
@@ -208,15 +209,15 @@ void db_copy_thread_t::thread_t::start_copy(
208209
}
209210

210211
sql.push_back('\0');
211-
m_conn->copy_start(sql.data());
212+
m_db_connection->copy_start(sql.data());
212213

213214
m_inflight = target;
214215
}
215216

216217
void db_copy_thread_t::thread_t::finish_copy()
217218
{
218219
if (m_inflight) {
219-
m_conn->copy_end(m_inflight->name());
220+
m_db_connection->copy_end(m_inflight->name());
220221
m_inflight.reset();
221222
}
222223
}

src/db-copy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class db_copy_thread_t
301301
void delete_rows(db_cmd_copy_t *buffer);
302302

303303
connection_params_t m_connection_params;
304-
std::unique_ptr<pg_conn_t> m_conn;
304+
std::unique_ptr<pg_conn_t> m_db_connection;
305305

306306
// Target for copy operation currently ongoing.
307307
std::shared_ptr<db_target_descr_t> m_inflight;

0 commit comments

Comments
 (0)