Skip to content

Commit

Permalink
Remove errors when converting empty numeric rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakwell committed Apr 8, 2020
1 parent 10e6938 commit 1e98c16
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions osquery/sql/dynamic_table_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ int DynamicTableRow::get_column(sqlite3_context* ctx,
} else if (type == TEXT_TYPE || type == BLOB_TYPE) {
sqlite3_result_text(
ctx, value.c_str(), static_cast<int>(value.size()), SQLITE_TRANSIENT);
} else if (value.empty() &&
(type == INTEGER_TYPE || type == BIGINT_TYPE ||
type == UNSIGNED_BIGINT_TYPE || type == DOUBLE_TYPE)) {
// Don't Log a casting error for a known type if the column row is empty
sqlite3_result_null(ctx);
} else if (type == INTEGER_TYPE) {
auto afinite = tryTo<long>(value, 0);
if (afinite.isError()) {
VLOG(1) << "Error casting " << column_name << " (" << value
<< ") to INTEGER";
<< ") to INTEGER. " << afinite.getError();
sqlite3_result_null(ctx);
} else {
sqlite3_result_int(ctx, afinite.take());
Expand All @@ -121,7 +126,7 @@ int DynamicTableRow::get_column(sqlite3_context* ctx,
auto afinite = tryTo<long long>(value, 0);
if (afinite.isError()) {
VLOG(1) << "Error casting " << column_name << " (" << value
<< ") to BIGINT";
<< ") to BIGINT. " << afinite.getError();
sqlite3_result_null(ctx);
} else {
sqlite3_result_int64(ctx, afinite.take());
Expand Down

0 comments on commit 1e98c16

Please sign in to comment.