mirror of
https://github.com/tstack/lnav
synced 2024-11-01 21:40:34 +00:00
[misc] fix a perf issue when previewing commands and some sql fixes
This commit is contained in:
parent
7d7060ae4c
commit
7f99955cbc
@ -87,6 +87,18 @@ public:
|
||||
values.push_back({this->alv_schema_name, schema_ref, 2});
|
||||
}
|
||||
|
||||
bool is_valid(log_cursor &lc, logfile_sub_source &lss) {
|
||||
content_line_t cl(lss.at(lc.lc_curr_line));
|
||||
logfile * lf = lss.find(cl);
|
||||
logfile::iterator lf_iter = lf->begin() + cl;
|
||||
|
||||
if (lf_iter->is_continued()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
bool next(log_cursor &lc, logfile_sub_source &lss) {
|
||||
lc.lc_curr_line = lc.lc_curr_line + vis_line_t(1);
|
||||
lc.lc_sub_index = 0;
|
||||
|
@ -636,6 +636,10 @@ static int vt_filter(sqlite3_vtab_cursor *p_vtc,
|
||||
}
|
||||
}
|
||||
|
||||
while (!p_cur->log_cursor.is_eof() && !vt->vi->is_valid(p_cur->log_cursor, *vt->lss)) {
|
||||
p_cur->log_cursor.lc_curr_line += vis_line_t(1);
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,18 @@ public:
|
||||
|
||||
std::string get_table_statement(void);
|
||||
|
||||
virtual bool is_valid(log_cursor &lc, logfile_sub_source &lss) {
|
||||
content_line_t cl(lss.at(lc.lc_curr_line));
|
||||
logfile * lf = lss.find(cl);
|
||||
logfile::iterator lf_iter = lf->begin() + cl;
|
||||
|
||||
if (lf_iter->is_continued()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
virtual bool next(log_cursor &lc, logfile_sub_source &lss) = 0;
|
||||
|
||||
virtual void get_columns(std::vector<vtab_column> &cols) const { };
|
||||
|
@ -52,7 +52,6 @@ void rl_change(void *dummy, readline_curses *rc)
|
||||
|
||||
tc->get_highlights().erase("$preview");
|
||||
tc->get_highlights().erase("$bodypreview");
|
||||
tc->reload_data();
|
||||
lnav_data.ld_preview_source.clear();
|
||||
lnav_data.ld_preview_status_source.get_description().clear();
|
||||
|
||||
|
@ -465,6 +465,22 @@ int register_sqlite_funcs(sqlite3 *db, sqlite_registration_func_t *reg_funcs)
|
||||
}
|
||||
|
||||
static help_text idents[] = {
|
||||
help_text("ATTACH",
|
||||
"Attach a database file to the current connection.")
|
||||
.sql_keyword()
|
||||
.with_parameter(help_text("filename", "The path to the database file.")
|
||||
.with_flag_name("DATABASE"))
|
||||
.with_parameter(help_text("schema-name", "The prefix for tables in this database.")
|
||||
.with_flag_name("AS"))
|
||||
.with_example({"ATTACH DATABASE '/tmp/customers.db' AS customers"}),
|
||||
|
||||
help_text("DETACH",
|
||||
"Detach a database from the current connection.")
|
||||
.sql_keyword()
|
||||
.with_parameter(help_text("schema-name", "The prefix for tables in this database.")
|
||||
.with_flag_name("DATABASE"))
|
||||
.with_example({"DETACH DATABASE customers"}),
|
||||
|
||||
help_text("SELECT",
|
||||
"Query the database and return zero or more rows of data.")
|
||||
.sql_keyword()
|
||||
|
@ -1806,6 +1806,19 @@ Parameter
|
||||
N The size of the BLOB.
|
||||
|
||||
|
||||
Synopsis
|
||||
ATTACH DATABASE filename AS schema-name
|
||||
|
||||
Attach a database file to the current connection.
|
||||
Parameters
|
||||
filename The path to the database file.
|
||||
schema-name The prefix for tables in this database.
|
||||
|
||||
Example
|
||||
#1 ;ATTACH DATABASE '/tmp/customers.db' AS customers
|
||||
|
||||
|
||||
|
||||
Synopsis
|
||||
CASE [base-expr] WHEN cmp-expr1 THEN then-expr1 [... WHEN cmp-exprN THEN then-exprN]
|
||||
[ELSE else-expr]
|
||||
@ -1824,6 +1837,18 @@ Example
|
||||
|
||||
|
||||
|
||||
Synopsis
|
||||
DETACH DATABASE schema-name
|
||||
|
||||
Detach a database from the current connection.
|
||||
Parameter
|
||||
schema-name The prefix for tables in this database.
|
||||
|
||||
Example
|
||||
#1 ;DETACH DATABASE customers
|
||||
|
||||
|
||||
|
||||
Synopsis
|
||||
SELECT result-column1 [, ... result-columnN] [FROM table1 [, ... tableN]]
|
||||
[WHERE cond]
|
||||
|
@ -889,6 +889,14 @@ check_output "multiline data is not right?" <<EOF
|
||||
]
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ";select log_text from generic_log where log_line = 1" \
|
||||
-c ":write-json-to -" \
|
||||
${test_dir}/logfile_multiline.0
|
||||
|
||||
check_output "able to select a continued line?" <<EOF
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":create-search-table search_test1 (\w+), world!" \
|
||||
|
Loading…
Reference in New Issue
Block a user