@@ -44,7 +44,7 @@ void show_memory_usage()
4444 }
4545}
4646
47- file_info run (options_t const &options, properties_t const & properties)
47+ file_info run (options_t const &options, properties_t * properties)
4848{
4949 auto const files = prepare_input_files (
5050 options.input_files , options.input_format , options.append );
@@ -57,10 +57,15 @@ file_info run(options_t const &options, properties_t const &properties)
5757 middle->start ();
5858
5959 auto output = output_t::create_output (middle->get_query_instance (),
60- thread_pool, options, properties);
60+ thread_pool, options, * properties);
6161
6262 middle->set_requirements (output->get_requirements ());
6363
64+ if (!options.append ) {
65+ properties->init_table ();
66+ }
67+ properties->store ();
68+
6469 osmdata_t osmdata{middle, output, options};
6570
6671 // Processing: In this phase the input file(s) are read and parsed,
@@ -93,8 +98,8 @@ void check_db(options_t const &options)
9398 check_schema (options.output_dbschema );
9499}
95100
96- // This is called in "create" mode to store properties into the database .
97- void store_properties (properties_t *properties, options_t const &options)
101+ // This is called in "create" mode to initialize properties.
102+ void set_up_properties (properties_t *properties, options_t const &options)
98103{
99104 properties->set_bool (" attributes" , options.extra_attributes );
100105
@@ -121,8 +126,6 @@ void store_properties(properties_t *properties, options_t const &options)
121126 std::filesystem::absolute (std::filesystem::path{options.style })
122127 .string ());
123128 }
124-
125- properties->store ();
126129}
127130
128131void store_data_properties (properties_t *properties, file_info const &finfo)
@@ -139,8 +142,6 @@ void store_data_properties(properties_t *properties, file_info const &finfo)
139142 properties->set_string (" replication_" + s, value);
140143 }
141144 }
142-
143- properties->store ();
144145}
145146
146147void check_updatable (properties_t const &properties)
@@ -206,7 +207,7 @@ void check_and_update_flat_node_file(properties_t *properties,
206207 " Using the flat node file you specified on the command line"
207208 " ('{}') instead of the one used on import ('{}')." ,
208209 absolute_path, flat_node_file_from_import);
209- properties->set_string (" flat_node_file" , absolute_path, true );
210+ properties->set_string (" flat_node_file" , absolute_path);
210211 }
211212 }
212213}
@@ -291,7 +292,7 @@ void check_and_update_style_file(properties_t *properties, options_t *options)
291292 log_info (" Using the style file you specified on the command line"
292293 " ('{}') instead of the one used on import ('{}')." ,
293294 absolute_path, style_file_from_import);
294- properties->set_string (" style" , absolute_path, true );
295+ properties->set_string (" style" , absolute_path);
295296}
296297
297298// This is called in "append" mode to check that the command line options are
@@ -348,6 +349,7 @@ int main(int argc, char *argv[])
348349
349350 properties_t properties{options.connection_params ,
350351 options.middle_dbschema };
352+
351353 if (options.append ) {
352354 if (!properties.load ()) {
353355 throw std::runtime_error{
@@ -356,8 +358,9 @@ int main(int argc, char *argv[])
356358 }
357359
358360 check_and_update_properties (&properties, &options);
361+ properties.store ();
359362
360- auto const finfo = run (options, properties);
363+ auto const finfo = run (options, & properties);
361364
362365 if (finfo.last_timestamp .valid ()) {
363366 auto const current_timestamp =
@@ -367,16 +370,18 @@ int main(int argc, char *argv[])
367370 (finfo.last_timestamp >
368371 osmium::Timestamp{current_timestamp})) {
369372 properties.set_string (" current_timestamp" ,
370- finfo.last_timestamp .to_iso (), true );
373+ finfo.last_timestamp .to_iso ());
371374 }
372375 }
373376 } else {
374377 set_option_defaults (&options);
375- store_properties (&properties, options);
376- auto const finfo = run (options, properties);
378+ set_up_properties (&properties, options);
379+ auto const finfo = run (options, & properties);
377380 store_data_properties (&properties, finfo);
378381 }
379382
383+ properties.store ();
384+
380385 show_memory_usage ();
381386 log_info (" osm2pgsql took {} overall." ,
382387 util::human_readable_duration (timer_overall.stop ()));
0 commit comments