@@ -1964,76 +1964,65 @@ void output_flex_t::relation_modify(osmium::Relation const &rel)
19641964 relation_add (rel);
19651965}
19661966
1967- void output_flex_t::init_clone ()
1967+ void output_flex_t::start ()
19681968{
19691969 for (auto &table : m_table_connections) {
19701970 table.connect (get_options ()->database_options .conninfo ());
1971- table.prepare ( );
1971+ table.start ( get_options ()-> append );
19721972 }
19731973}
19741974
1975- void output_flex_t::start ()
1975+ output_flex_t ::output_flex_t (output_flex_t const *other,
1976+ std::shared_ptr<middle_query_t > mid,
1977+ std::shared_ptr<db_copy_thread_t > copy_thread)
1978+ : output_t (other, std::move(mid)), m_tables(other->m_tables),
1979+ m_stage2_way_ids (other->m_stage2_way_ids),
1980+ m_copy_thread(std::move(copy_thread)), m_lua_state(other->m_lua_state),
1981+ m_expire(other->get_options ()->expire_tiles_zoom,
1982+ other->get_options()->expire_tiles_max_bbox,
1983+ other->get_options()->projection),
1984+ m_process_node(other->m_process_node), m_process_way(other->m_process_way),
1985+ m_process_relation(other->m_process_relation),
1986+ m_select_relation_members(other->m_select_relation_members)
19761987{
1977- for (auto &table : m_table_connections) {
1978- table.connect (get_options ()->database_options .conninfo ());
1979- table.start (get_options ()->append );
1988+ for (auto &table : *m_tables) {
1989+ auto &tc = m_table_connections.emplace_back (&table, m_copy_thread);
1990+ tc.connect (get_options ()->database_options .conninfo ());
1991+ tc.prepare ();
19801992 }
19811993}
19821994
19831995std::shared_ptr<output_t >
19841996output_flex_t ::clone(std::shared_ptr<middle_query_t > const &mid,
19851997 std::shared_ptr<db_copy_thread_t > const ©_thread) const
19861998{
1987- return std::make_shared<output_flex_t >(
1988- mid, m_thread_pool, *get_options (), copy_thread, true , m_lua_state,
1989- m_process_node, m_process_way, m_process_relation,
1990- m_select_relation_members, m_tables, m_stage2_way_ids);
1999+ return std::make_shared<output_flex_t >(this , mid, copy_thread);
19912000}
19922001
19932002output_flex_t ::output_flex_t (
19942003 std::shared_ptr<middle_query_t > const &mid,
19952004 std::shared_ptr<thread_pool_t > thread_pool, options_t const &o,
1996- std::shared_ptr<db_copy_thread_t > const ©_thread, bool is_clone,
1997- std::shared_ptr<lua_State> lua_state, prepared_lua_function_t process_node,
1998- prepared_lua_function_t process_way,
1999- prepared_lua_function_t process_relation,
2000- prepared_lua_function_t select_relation_members,
2001- std::shared_ptr<std::vector<flex_table_t >> tables,
2002- std::shared_ptr<idset_t > stage2_way_ids)
2003- : output_t (mid, std::move(thread_pool), o), m_tables(std::move(tables)),
2004- m_stage2_way_ids (std::move(stage2_way_ids)), m_copy_thread(copy_thread),
2005- m_lua_state(std::move(lua_state)),
2006- m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection),
2007- m_process_node(process_node), m_process_way(process_way),
2008- m_process_relation(process_relation),
2009- m_select_relation_members(select_relation_members)
2010- {
2011- assert (copy_thread);
2012-
2013- if (!is_clone) {
2014- init_lua (get_options ()->style );
2015-
2016- // If the osm2pgsql.select_relation_members() Lua function is defined
2017- // it means we need two-stage processing which in turn means we need
2018- // the full ways stored in the middle.
2019- if (m_select_relation_members) {
2020- m_output_requirements.full_ways = true ;
2021- }
2005+ std::shared_ptr<db_copy_thread_t > const ©_thread)
2006+ : output_t (mid, std::move(thread_pool), o), m_copy_thread(copy_thread),
2007+ m_expire (o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection)
2008+ {
2009+ init_lua (get_options ()->style );
2010+
2011+ // If the osm2pgsql.select_relation_members() Lua function is defined
2012+ // it means we need two-stage processing which in turn means we need
2013+ // the full ways stored in the middle.
2014+ if (m_select_relation_members) {
2015+ m_output_requirements.full_ways = true ;
20222016 }
20232017
20242018 if (m_tables->empty ()) {
20252019 throw std::runtime_error{
20262020 " No tables defined in Lua config. Nothing to do!" };
20272021 }
20282022
2029- assert (m_table_connections.empty ());
20302023 for (auto &table : *m_tables) {
20312024 m_table_connections.emplace_back (&table, m_copy_thread);
20322025 }
2033-
2034- if (is_clone) {
2035- init_clone ();
2036- }
20372026}
20382027
20392028/* *
0 commit comments