File tree 2 files changed +20
-8
lines changed
2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,14 @@ void middle_pgsql_t::table_desc::build_index(
176
176
}
177
177
}
178
178
179
+ void middle_pgsql_t::table_desc::create_table (
180
+ pg_conn_t const &db_connection) const
181
+ {
182
+ if (!m_create_table.empty ()) {
183
+ db_connection.exec (m_create_table);
184
+ }
185
+ }
186
+
179
187
void middle_pgsql_t::table_desc::init_max_id (pg_conn_t const &db_connection)
180
188
{
181
189
auto const qual_name = qualified_name (schema (), name ());
@@ -1315,9 +1323,7 @@ static void table_setup(pg_conn_t const &db_connection,
1315
1323
log_debug (" Setting up table '{}'" , table.name ());
1316
1324
auto const qual_name = qualified_name (table.schema (), table.name ());
1317
1325
db_connection.exec (" DROP TABLE IF EXISTS {} CASCADE" , qual_name);
1318
- if (!table.m_create_table .empty ()) {
1319
- db_connection.exec (table.m_create_table );
1320
- }
1326
+ table.create_table (db_connection);
1321
1327
}
1322
1328
1323
1329
void middle_pgsql_t::start ()
@@ -1730,7 +1736,7 @@ middle_pgsql_t::get_query_instance()
1730
1736
1731
1737
// We use a connection per table to enable the use of COPY
1732
1738
for (auto &table : m_tables) {
1733
- for (auto const &query : table.m_prepare_queries ) {
1739
+ for (auto const &query : table.prepare_queries () ) {
1734
1740
mid->exec_sql (query);
1735
1741
}
1736
1742
}
Original file line number Diff line number Diff line change @@ -153,22 +153,28 @@ struct middle_pgsql_t : public middle_t
153
153
// /< Open a new database connection and build index on this table.
154
154
void build_index (connection_params_t const &connection_params) const ;
155
155
156
- std::string m_create_table;
157
- std::vector<std::string> m_prepare_queries;
158
- std::vector<std::string> m_create_fw_dep_indexes;
159
-
160
156
void task_set (std::future<std::chrono::microseconds> &&future)
161
157
{
162
158
m_task_result.set (std::move (future));
163
159
}
164
160
165
161
std::chrono::microseconds task_wait () { return m_task_result.wait (); }
166
162
163
+ void create_table (pg_conn_t const &db_connection) const ;
164
+
167
165
void init_max_id (pg_conn_t const &db_connection);
168
166
169
167
osmid_t max_id () const noexcept { return m_max_id; }
170
168
169
+ std::vector<std::string> const &prepare_queries () const noexcept
170
+ {
171
+ return m_prepare_queries;
172
+ }
173
+
171
174
private:
175
+ std::string m_create_table;
176
+ std::vector<std::string> m_create_fw_dep_indexes;
177
+ std::vector<std::string> m_prepare_queries;
172
178
std::shared_ptr<db_target_descr_t > m_copy_target;
173
179
task_result_t m_task_result;
174
180
You can’t perform that action at this time.
0 commit comments