[sql] missed checking for null in graphable columns

This commit is contained in:
Timothy Stack 2015-11-29 20:10:40 -08:00
parent 62075fb340
commit 5a718bc0ec
4 changed files with 22 additions and 5 deletions

View File

@ -39,8 +39,8 @@ AC_PROG_CXX
CPPFLAGS="$CPPFLAGS -D_ISOC99_SOURCE -D__STDC_LIMIT_MACROS" CPPFLAGS="$CPPFLAGS -D_ISOC99_SOURCE -D__STDC_LIMIT_MACROS"
CFLAGS=`echo $CFLAGS | sed 's/-O2//g'` # CFLAGS=`echo $CFLAGS | sed 's/-O2//g'`
CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'` # CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'`
AC_ARG_VAR(SFTP_TEST_URL) AC_ARG_VAR(SFTP_TEST_URL)

View File

@ -425,14 +425,14 @@ int sql_callback(sqlite3_stmt *stmt)
double num_value = 0.0; double num_value = 0.0;
dls.push_column(value); dls.push_column(value);
if (dls.dls_headers[lpc] == "log_line") { if (value != NULL && dls.dls_headers[lpc] == "log_line") {
int line_number = -1; int line_number = -1;
if (sscanf(value, "%d", &line_number) == 1) { if (sscanf(value, "%d", &line_number) == 1) {
lss.text_mark(&BM_QUERY, line_number, true); lss.text_mark(&BM_QUERY, line_number, true);
} }
} }
if (dls.dls_headers_to_graph[lpc]) { if (value != NULL && dls.dls_headers_to_graph[lpc]) {
if (sscanf(value, "%lf", &num_value) != 1) { if (sscanf(value, "%lf", &num_value) != 1) {
num_value = 0.0; num_value = 0.0;
} }

View File

@ -714,7 +714,6 @@ string log_vtab_manager::unregister_vtab(intern_string_t name)
NULL, NULL,
NULL, NULL,
NULL); NULL);
require(rc == SQLITE_OK);
this->vm_impls.erase(name); this->vm_impls.erase(name);
} }

View File

@ -626,3 +626,21 @@ run_test ${lnav_test} -n \
check_error_output "able to create table with a bad regex?" <<EOF check_error_output "able to create table with a bad regex?" <<EOF
error: unable to compile regex -- bad( error: unable to compile regex -- bad(
EOF EOF
NULL_GRAPH_SELECT_1=$(cat <<EOF
;SELECT value FROM (
SELECT 10 as value
UNION ALL SELECT null as value)
EOF
)
run_test ${lnav_test} -n \
-c "$NULL_GRAPH_SELECT_1" \
-c ":write-csv-to -" \
${test_dir}/logfile_multiline.0
check_output "number column with null does not work?" <<EOF
value
10
<NULL>
EOF