mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 00:40:30 +03:00
parent
cccc72f3c1
commit
842eabb4af
@ -914,7 +914,7 @@ execute_init_commands(
|
||||
wait_for_pipers(deadline);
|
||||
rebuild_indexes_repeatedly();
|
||||
}
|
||||
if (dls.dls_rows.size() > 1 && lnav_data.ld_view_stack.size() == 1)
|
||||
if (!dls.dls_headers.empty() && lnav_data.ld_view_stack.size() == 1)
|
||||
{
|
||||
lnav_data.ld_views[LNV_DB].reload_data();
|
||||
ensure_view(LNV_DB);
|
||||
@ -951,36 +951,38 @@ execute_init_commands(
|
||||
int
|
||||
sql_callback(exec_context& ec, sqlite3_stmt* stmt)
|
||||
{
|
||||
const auto& vc = view_colors::singleton();
|
||||
auto& dls = *(ec.ec_label_source_stack.back());
|
||||
int ncols = sqlite3_column_count(stmt);
|
||||
|
||||
if (!sqlite3_stmt_busy(stmt)) {
|
||||
dls.clear();
|
||||
|
||||
for (int lpc = 0; lpc < ncols; lpc++) {
|
||||
const int type = sqlite3_column_type(stmt, lpc);
|
||||
std::string colname = sqlite3_column_name(stmt, lpc);
|
||||
|
||||
dls.push_header(colname, type, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto& vc = view_colors::singleton();
|
||||
int ncols = sqlite3_column_count(stmt);
|
||||
int row_number;
|
||||
int lpc, retval = 0;
|
||||
auto set_vars = false;
|
||||
int retval = 0;
|
||||
auto set_vars = dls.dls_rows.empty();
|
||||
|
||||
row_number = dls.dls_rows.size();
|
||||
dls.dls_rows.resize(row_number + 1);
|
||||
if (dls.dls_headers.empty()) {
|
||||
for (lpc = 0; lpc < ncols; lpc++) {
|
||||
if (dls.dls_rows.empty()) {
|
||||
for (int lpc = 0; lpc < ncols; lpc++) {
|
||||
int type = sqlite3_column_type(stmt, lpc);
|
||||
std::string colname = sqlite3_column_name(stmt, lpc);
|
||||
bool graphable;
|
||||
|
||||
graphable = ((type == SQLITE_INTEGER || type == SQLITE_FLOAT)
|
||||
bool graphable = (type == SQLITE_INTEGER || type == SQLITE_FLOAT)
|
||||
&& !binary_search(lnav_data.ld_db_key_names.begin(),
|
||||
lnav_data.ld_db_key_names.end(),
|
||||
colname));
|
||||
|
||||
dls.push_header(colname, type, graphable);
|
||||
colname);
|
||||
auto& hm = dls.dls_headers[lpc];
|
||||
hm.hm_column_type = type;
|
||||
hm.hm_graphable = graphable;
|
||||
if (graphable) {
|
||||
auto& hm = dls.dls_headers.back();
|
||||
auto name_for_ident_attrs = colname;
|
||||
auto attrs = vc.attrs_for_ident(name_for_ident_attrs);
|
||||
for (size_t attempt = 0;
|
||||
@ -991,14 +993,17 @@ sql_callback(exec_context& ec, sqlite3_stmt* stmt)
|
||||
attrs = vc.attrs_for_ident(name_for_ident_attrs);
|
||||
}
|
||||
hm.hm_chart.with_attrs_for_ident(colname, attrs);
|
||||
dls.dls_headers.back().hm_title_attrs = attrs;
|
||||
hm.hm_title_attrs = attrs;
|
||||
hm.hm_column_size = std::max(hm.hm_column_size, size_t{10});
|
||||
}
|
||||
}
|
||||
set_vars = true;
|
||||
}
|
||||
for (lpc = 0; lpc < ncols; lpc++) {
|
||||
|
||||
auto row_number = dls.dls_rows.size();
|
||||
dls.dls_rows.resize(row_number + 1);
|
||||
for (int lpc = 0; lpc < ncols; lpc++) {
|
||||
auto* raw_value = sqlite3_column_value(stmt, lpc);
|
||||
auto value_type = sqlite3_value_type(raw_value);
|
||||
const auto value_type = sqlite3_value_type(raw_value);
|
||||
scoped_value_t value;
|
||||
auto& hm = dls.dls_headers[lpc];
|
||||
|
||||
|
@ -337,6 +337,7 @@ SELECT *result-column* FROM *table* WHERE *\[cond\]* GROUP BY *grouping-expr* OR
|
||||
.. code-block:: custsqlite
|
||||
|
||||
;SELECT * FROM syslog_log
|
||||
log_line log_time log_level log_hostname log_msgid log_pid log_pri log_procname log_struct log_syslog_tag syslog_version log_part log_idle_msecs log_mark log_comment log_tags log_annotations log_filters
|
||||
|
||||
|
||||
----
|
||||
|
@ -4397,6 +4397,7 @@ com_summarize(exec_context& ec,
|
||||
} else {
|
||||
bool done = false;
|
||||
|
||||
ec.ec_sql_callback(ec, stmt.in());
|
||||
while (!done) {
|
||||
retcode = sqlite3_step(stmt.in());
|
||||
|
||||
|
@ -52,6 +52,20 @@
|
||||
|
||||
using namespace lnav::roles::literals;
|
||||
|
||||
static bool
|
||||
file_needs_reformatting(const std::shared_ptr<logfile> lf)
|
||||
{
|
||||
switch (lf->get_text_format()) {
|
||||
case text_format_t::TF_DIFF:
|
||||
return false;
|
||||
default:
|
||||
if (lf->get_longest_line_length() > 240) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
textfile_sub_source::text_line_count()
|
||||
{
|
||||
@ -990,7 +1004,7 @@ textfile_sub_source::rescan_files(textfile_sub_source::scan_callback& callback,
|
||||
lf->get_filename().c_str(),
|
||||
read_res.unwrapErr().c_str());
|
||||
}
|
||||
} else if (lf->get_longest_line_length() > 240) {
|
||||
} else if (file_needs_reformatting(lf)) {
|
||||
auto rend_iter
|
||||
= this->tss_rendered_files.find(lf->get_filename());
|
||||
if (rend_iter != this->tss_rendered_files.end()) {
|
||||
|
@ -296,6 +296,7 @@ dist_noinst_DATA = \
|
||||
datafile_xml.0 \
|
||||
dhcp.pcapng \
|
||||
dhcp-trunc.pcapng \
|
||||
empty-result.lnav \
|
||||
example.patch \
|
||||
example.toml \
|
||||
expected_help.txt \
|
||||
|
1
test/empty-result.lnav
Normal file
1
test/empty-result.lnav
Normal file
@ -0,0 +1 @@
|
||||
;SELECT * FROM syslog_log LIMIT 0
|
@ -161,12 +161,13 @@ Wed May 19 12:00:04 +0000 2021 line 4
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
run_cap_test ${lnav_test} -n \
|
||||
-c ";SELECT * FROM access_log LIMIT 0" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "output generated for empty result set?" <<EOF
|
||||
EOF
|
||||
run_cap_test ${lnav_test} -n \
|
||||
-c "|${test_dir}/empty-result.lnav" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
run_cap_test ${lnav_test} -n \
|
||||
-c ":goto 2" \
|
||||
@ -389,6 +390,7 @@ run_test ${lnav_test} -n \
|
||||
${test_dir}/logfile_syslog.0
|
||||
|
||||
check_output "log_time collation failed on null" <<EOF
|
||||
log_line,log_time,log_level,log_hostname,log_msgid,log_pid,log_pri,log_procname,log_struct,log_syslog_tag,syslog_version,log_part,log_idle_msecs,log_mark,log_comment,log_tags,log_annotations,log_filters
|
||||
EOF
|
||||
|
||||
|
||||
@ -549,6 +551,7 @@ run_test ${lnav_test} -n \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "delete from environ table does not work" <<EOF
|
||||
name,value
|
||||
EOF
|
||||
|
||||
|
||||
@ -559,6 +562,7 @@ run_test ${lnav_test} -n \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "delete environ table does not work" <<EOF
|
||||
name,value
|
||||
EOF
|
||||
|
||||
|
||||
@ -777,6 +781,9 @@ run_test ${lnav_test} -n \
|
||||
${test_dir}/logfile_multiline.0
|
||||
|
||||
check_output "able to select a continued line?" <<EOF
|
||||
[
|
||||
|
||||
]
|
||||
EOF
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user