mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[misc] some more miscellaneous bugs
Defect Number: Reviewed By: Testing Done:
This commit is contained in:
parent
05730274ed
commit
a973f7f934
@ -128,7 +128,6 @@ string execute_sql(exec_context &ec, const string &sql, string &alt_msg)
|
||||
stmt_str = MSG_FORMAT_STMT;
|
||||
}
|
||||
|
||||
dls.clear();
|
||||
ec.ec_accumulator.clear();
|
||||
sql_progress_guard progress_guard(sql_progress);
|
||||
gettimeofday(&start_tv, NULL);
|
||||
@ -226,7 +225,7 @@ string execute_sql(exec_context &ec, const string &sql, string &alt_msg)
|
||||
lnav_data.ld_rl_view->set_value("Executing query: " + sql + " ...");
|
||||
}
|
||||
|
||||
lnav_data.ld_log_source.text_clear_marks(&BM_QUERY);
|
||||
ec.ec_sql_callback(ec, stmt.in());
|
||||
while (!done) {
|
||||
retcode = sqlite3_step(stmt.in());
|
||||
|
||||
@ -638,8 +637,16 @@ void execute_init_commands(exec_context &ec, vector<pair<string, string> > &msgs
|
||||
|
||||
int sql_callback(exec_context &ec, sqlite3_stmt *stmt)
|
||||
{
|
||||
logfile_sub_source &lss = lnav_data.ld_log_source;
|
||||
db_label_source &dls = lnav_data.ld_db_row_source;
|
||||
logfile_sub_source &lss = lnav_data.ld_log_source;
|
||||
|
||||
if (!sqlite3_stmt_busy(stmt)) {
|
||||
dls.clear();
|
||||
lss.text_clear_marks(&BM_QUERY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
stacked_bar_chart<std::string> &chart = dls.dls_chart;
|
||||
view_colors &vc = view_colors::singleton();
|
||||
int ncols = sqlite3_column_count(stmt);
|
||||
@ -676,7 +683,8 @@ int sql_callback(exec_context &ec, sqlite3_stmt *stmt)
|
||||
int line_number = -1;
|
||||
|
||||
if (sscanf(value, "%d", &line_number) == 1) {
|
||||
lss.text_mark(&BM_QUERY, line_number, true);
|
||||
lnav_data.ld_views[LNV_LOG].toggle_user_mark(
|
||||
&BM_QUERY, vis_line_t(line_number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -831,6 +831,12 @@ void handle_paging_key(int ch)
|
||||
++iter) {
|
||||
lnav_data.ld_rl_view->add_possibility(LNM_COMMAND, "colname", *iter);
|
||||
}
|
||||
for (auto iter : ldh.ldh_namer->cn_builtin_names) {
|
||||
if (iter == "col") {
|
||||
continue;
|
||||
}
|
||||
lnav_data.ld_rl_view->add_possibility(LNM_COMMAND, "colname", iter);
|
||||
}
|
||||
|
||||
ldh.clear();
|
||||
|
||||
|
@ -183,7 +183,7 @@ bool listview_curses::handle_key(int ch)
|
||||
|
||||
void listview_curses::do_update(void)
|
||||
{
|
||||
if (this->lv_window == NULL) {
|
||||
if (this->lv_window == NULL || this->lv_height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
49
src/lnav.cc
49
src/lnav.cc
@ -735,6 +735,10 @@ static void open_schema_view(void)
|
||||
|
||||
static int pretty_sql_callback(exec_context &ec, sqlite3_stmt *stmt)
|
||||
{
|
||||
if (!sqlite3_stmt_busy(stmt)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ncols = sqlite3_column_count(stmt);
|
||||
|
||||
for (int lpc = 0; lpc < ncols; lpc++) {
|
||||
@ -848,6 +852,32 @@ static void open_pretty_view(void)
|
||||
redo_search(LNV_PRETTY);
|
||||
}
|
||||
|
||||
static int key_sql_callback(exec_context &ec, sqlite3_stmt *stmt)
|
||||
{
|
||||
if (!sqlite3_stmt_busy(stmt)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ncols = sqlite3_column_count(stmt);
|
||||
|
||||
auto &vars = ec.ec_local_vars.top();
|
||||
|
||||
for (int lpc = 0; lpc < ncols; lpc++) {
|
||||
const char *column_name = sqlite3_column_name(stmt, lpc);
|
||||
|
||||
if (sql_ident_needs_quote(column_name)) {
|
||||
continue;
|
||||
}
|
||||
if (sqlite3_column_type(stmt, lpc) == SQLITE_NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vars[column_name] = string((const char *) sqlite3_column_text(stmt, lpc));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool toggle_view(textview_curses *toggle_tc)
|
||||
{
|
||||
textview_curses *tc = lnav_data.ld_view_stack.empty() ? NULL : lnav_data.ld_view_stack.back();
|
||||
@ -1724,6 +1754,14 @@ static void handle_key(int ch) {
|
||||
lnav_data.ld_input_state.push_back(ch);
|
||||
|
||||
if (lnav_data.ld_mode == LNM_PAGING) {
|
||||
if (!lnav_data.ld_view_stack.empty()) {
|
||||
textview_curses *tc = lnav_data.ld_view_stack.back();
|
||||
|
||||
if (tc->handle_key(ch)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char keyseq[16];
|
||||
|
||||
snprintf(keyseq, sizeof(keyseq), "x%02x", ch);
|
||||
@ -1732,16 +1770,19 @@ static void handle_key(int ch) {
|
||||
|
||||
const auto &iter = km.km_seq_to_cmd.find(keyseq);
|
||||
if (iter != km.km_seq_to_cmd.end()) {
|
||||
auto &var_stack = lnav_data.ld_exec_context.ec_local_vars;
|
||||
vector<logline_value> values;
|
||||
exec_context ec(&values, key_sql_callback, pipe_callback);
|
||||
auto &var_stack = ec.ec_local_vars;
|
||||
string result;
|
||||
|
||||
ec.ec_global_vars = lnav_data.ld_exec_context.ec_global_vars;
|
||||
var_stack.push(map<string, string>());
|
||||
auto &vars = var_stack.top();
|
||||
vars["keyseq"] = keyseq;
|
||||
for (string cmd : iter->second) {
|
||||
log_debug("executing key sequence x%02x: %s",
|
||||
keyseq, cmd.c_str());
|
||||
result = execute_any(lnav_data.ld_exec_context, cmd);
|
||||
result = execute_any(ec, cmd);
|
||||
}
|
||||
|
||||
lnav_data.ld_rl_view->set_value(result);
|
||||
@ -1924,14 +1965,14 @@ static void layout_views()
|
||||
- lnav_data.ld_rl_view->get_height());
|
||||
lnav_data.ld_status[LNS_PREVIEW].set_enabled(preview_status_open);
|
||||
|
||||
if (doc_side_by_side) {
|
||||
if (!doc_open || doc_side_by_side) {
|
||||
lnav_data.ld_doc_view.set_height(vis_line_t(doc_height));
|
||||
} else {
|
||||
lnav_data.ld_doc_view.set_height(vis_line_t(lnav_data.ld_doc_source.text_line_count()));
|
||||
}
|
||||
lnav_data.ld_doc_view.set_y(height - bottom_height + 1);
|
||||
|
||||
if (doc_side_by_side) {
|
||||
if (!doc_open || doc_side_by_side) {
|
||||
lnav_data.ld_example_view.set_height(vis_line_t(doc_height));
|
||||
lnav_data.ld_example_view.set_x(90);
|
||||
lnav_data.ld_example_view.set_y(height - bottom_height + 1);
|
||||
|
@ -2334,6 +2334,7 @@ static string com_toggle_field(exec_context &ec, string cmdline, vector<string>
|
||||
} else if (tc->get_inner_height() == 0) {
|
||||
retval = "error: no log messages to hide";
|
||||
} else if (ec.ec_dry_run) {
|
||||
// TODO: highlight the fields to be hidden.
|
||||
retval = "";
|
||||
} else {
|
||||
logfile_sub_source &lss = lnav_data.ld_log_source;
|
||||
|
@ -73,7 +73,7 @@ compare_right(int a_len, nat_char const *a, int b_len, nat_char const *b, int *l
|
||||
remember it in BIAS. */
|
||||
for (;; a++, b++, a_len--, b_len--, (*len_out)++) {
|
||||
if (a_len == 0 && b_len == 0)
|
||||
return 0;
|
||||
return bias;
|
||||
if (a_len == 0)
|
||||
return -1;
|
||||
if (b_len == 0)
|
||||
|
@ -209,6 +209,18 @@ log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,c_ip,cs_method,cs_r
|
||||
1,<NULL>,2009-07-20 22:59:29.000,3000,error,0,192.168.202.254,GET,-,<NULL>,/vmw/vSphere/default/vmkboot.gz,gPXE/0.9.7,-,HTTP/1.0,46210,404
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":goto 0" \
|
||||
-c ";select log_line from access_log where log_level >= 'warning'" \
|
||||
-c ":switch-to-view log" \
|
||||
-c ":next-mark query" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "query bookmark not working?" <<EOF
|
||||
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
|
||||
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
|
||||
EOF
|
||||
|
||||
|
||||
# XXX The timestamp on the file is used to determine the year for syslog files.
|
||||
touch -t 201311030923 ${test_dir}/logfile_syslog.0
|
||||
|
@ -14,6 +14,13 @@ Row 0:
|
||||
Column '192.168.1.10' < '192.168.1.2' collate ipaddress: 0
|
||||
EOF
|
||||
|
||||
run_test ./drive_sql "select '192.168.1.10' < '192.168.1.12' collate ipaddress"
|
||||
|
||||
check_output "" <<EOF
|
||||
Row 0:
|
||||
Column '192.168.1.10' < '192.168.1.12' collate ipaddress: 1
|
||||
EOF
|
||||
|
||||
run_test ./drive_sql "select '::ffff:192.168.1.10' = '192.168.1.10' collate ipaddress"
|
||||
|
||||
check_output "" <<EOF
|
||||
|
Loading…
Reference in New Issue
Block a user