Skip to content

Commit a07f005

Browse files
authored
Merge pull request #1907 from joto/insert-and-error-counter
Add row insert and not-null error counter to tables
2 parents 1bad5da + 99ab485 commit a07f005

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/flex-table.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,7 @@ void table_connection_t::task_wait()
421421
auto const run_time = m_task_result.wait();
422422
log_info("All postprocessing on table '{}' done in {}.", table().name(),
423423
util::human_readable_duration(run_time));
424+
log_debug("Inserted {} rows into table '{}' ({} not inserted due to"
425+
" NOT NULL constraints).",
426+
m_count_insert, table().name(), m_count_not_null_error);
424427
}

src/flex-table.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ class table_connection_t
273273

274274
void task_wait();
275275

276+
void increment_insert_counter() noexcept { ++m_count_insert; }
277+
278+
void increment_not_null_error_counter() noexcept
279+
{
280+
++m_count_not_null_error;
281+
}
282+
276283
private:
277284
std::shared_ptr<reprojection> m_proj;
278285

@@ -291,6 +298,9 @@ class table_connection_t
291298

292299
task_result_t m_task_result;
293300

301+
std::size_t m_count_insert = 0;
302+
std::size_t m_count_not_null_error = 0;
303+
294304
/// Has the Id index already been created?
295305
bool m_id_index_created = false;
296306

src/output-flex.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,15 @@ int output_flex_t::table_insert()
693693
flex_write_column(lua_state(), copy_mgr, column, &m_expire);
694694
}
695695
}
696+
table_connection.increment_insert_counter();
696697
} catch (not_null_exception const &e) {
697698
copy_mgr->rollback_line();
698699
lua_pushboolean(lua_state(), false);
699700
lua_pushstring(lua_state(), "null value in not null column.");
700701
lua_pushstring(lua_state(), e.column().name().c_str());
701702
push_osm_object_to_lua_stack(lua_state(), object,
702703
get_options()->extra_attributes);
704+
table_connection.increment_not_null_error_counter();
703705
return 4;
704706
}
705707

0 commit comments

Comments
 (0)