From e7ed8d0ae96ff0f64d4c4db6a257a40c0008c2ef Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Tue, 11 Jun 2024 15:45:25 +0200 Subject: [PATCH] Allow empty config file in flex output No flex config file, or one that doesn't define any tables is usually not very useful. But it can be used in slim mode to have the middle tables only. Or it can be used to do some other processing or instead if the null output for testing. This change allows an empty config file, but a warning is printed that no output tables are defined. You still have to specify a config file, it can be an empty one, but it has to be there. This is so that if the user forgets naming a config file on the command line they get an error and not only a warning that might be missed. --- src/output-flex.cpp | 3 +-- tests/bdd/flex/lua-basics.feature | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/output-flex.cpp b/src/output-flex.cpp index a52f10c09..290dc9d98 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -1172,8 +1172,7 @@ output_flex_t::output_flex_t(std::shared_ptr const &mid, } if (m_tables->empty()) { - throw std::runtime_error{ - "No tables defined in Lua config. Nothing to do!"}; + log_warn("No output tables defined!"); } // For backwards compatibility we add a "default" expire output to all diff --git a/tests/bdd/flex/lua-basics.feature b/tests/bdd/flex/lua-basics.feature index 669933f1d..b8d68923a 100644 --- a/tests/bdd/flex/lua-basics.feature +++ b/tests/bdd/flex/lua-basics.feature @@ -9,10 +9,10 @@ Feature: Flex output uses a Lua config file print("stage=" .. osm2pgsql.stage) print("Table=" .. type(osm2pgsql.Table)) """ - Then running osm2pgsql flex fails - And the error output contains + When running osm2pgsql flex + Then the error output contains """ - No tables defined in Lua config. Nothing to do! + No output tables defined """ And the standard output contains """