Skip to content

Commit 9982eb8

Browse files
committed
Clean up middle --slim --drop logic
1 parent e84da10 commit 9982eb8

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

middle-pgsql.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ void middle_pgsql_t::start(const options_t *out_options_)
10421042
{
10431043
out_options = out_options_;
10441044
int i;
1045-
bool dropcreate = !out_options->append;
1045+
bool dropcreate = !out_options->append; ///< If tables need to be dropped and created anew
10461046

10471047
ways_pending_tracker.reset(new id_tracker());
10481048
rels_pending_tracker.reset(new id_tracker());
@@ -1061,7 +1061,7 @@ void middle_pgsql_t::start(const options_t *out_options_)
10611061
append = out_options->append;
10621062
// reset this on every start to avoid options from last run
10631063
// staying set for the second.
1064-
build_indexes = 0;
1064+
build_indexes = !append && !out_options->droptemp;
10651065

10661066
cache.reset(new node_ram_cache( out_options->alloc_chunkwise | ALLOC_LOSSY, out_options->cache, out_options->scale));
10671067
if (out_options->flat_node_cache_enabled) persistent_cache.reset(new node_persistent_cache(out_options, out_options->append, false, cache));
@@ -1089,15 +1089,6 @@ void middle_pgsql_t::start(const options_t *out_options_)
10891089
*/
10901090
pgsql_exec(sql_conn, PGRES_COMMAND_OK, "SET synchronous_commit TO off;");
10911091

1092-
/* Not really the right place for this test, but we need a live
1093-
* connection that not used for anything else yet, and we'd like to
1094-
* warn users *before* we start doing mountains of work */
1095-
if (i == t_node)
1096-
{
1097-
if(!out_options->append)
1098-
build_indexes = 1;
1099-
}
1100-
11011092
pgsql_exec(sql_conn, PGRES_COMMAND_OK, "SET client_min_messages = WARNING");
11021093
if (dropcreate) {
11031094
pgsql_exec(sql_conn, PGRES_COMMAND_OK, "DROP TABLE IF EXISTS %s", tables[i].name);
@@ -1229,7 +1220,7 @@ void middle_pgsql_t::stop(void)
12291220

12301221
middle_pgsql_t::middle_pgsql_t()
12311222
: tables(), num_tables(0), node_table(nullptr), way_table(nullptr), rel_table(nullptr),
1232-
append(false), mark_pending(true), cache(), persistent_cache(), build_indexes(0)
1223+
append(false), mark_pending(true), cache(), persistent_cache(), build_indexes(true)
12331224
{
12341225
/*table = t_node,*/
12351226
tables.push_back(table_desc(

middle-pgsql.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct middle_pgsql_t : public slim_middle_t {
104104

105105
std::shared_ptr<id_tracker> ways_pending_tracker, rels_pending_tracker;
106106

107-
int build_indexes;
107+
bool build_indexes;
108108
};
109109

110110
#endif

0 commit comments

Comments
 (0)