Skip to content

SQL ";.save" command does not seem to work as advertised #1589

@dardhal

Description

@dardhal

lnav version
lnav 0.14.0-a2e2380-dirty

Describe the bug
As per #1525 a new SQL feature was introduced, so a ".save" command would create a SQLite3 database file in the running host containing the "tables that were created whilst working with the log data".

However, running the very same commands found in the "test/test_sql.sh" file does not work as expected (it creates the .db file but it has no data).

To Reproduce

  • Open up a log file of "syslog_log" type, to perfectly match the example in the test file (although this should be irrelevant)
  • Confirm the format-specific database has data:
;SELECT COUNT(*) FROM syslog_log
✔ SQL Result: 18336
  • Create a user table running the same command as in "lnav" SQL test script, and confirm is has data:
;CREATE TABLE syslog_copy AS SELECT * FROM syslog_log
;SELECT COUNT(*) FROM syslog_copy
✔ SQL Result: 18336
  • Now run the "save" command as in the test file:
;.save syslog_copy.db
  • And see what the output is (file exists but it is an empty SQLite DB file):
$ ls -l syslog_copy.db 
-rw-r-----. 1 user group 4096 Nov 20 10:19 syslog_copy.db

$ echo ".dump" | sqlite3 syslog_copy.db 
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
COMMIT;

The debug file includes the following detail for the saving of the user DB:

2025-11-20T10:19:24.193977+01:00 I t0 [182007::user_input-103] view_helpers.cc:1730 changing mode from SQL to PAGING
2025-11-20T10:19:24.194013+01:00 I t0 [182007::user_input-103::execute_sql-6] command_executor.cc:357 Executing SQL: .save syslog_copy.db
2025-11-20T10:19:24.194064+01:00 I t2 [182007::backup_user_db-0] sql_commands.cc:208 starting backup of user DB: syslog_copy.db
2025-11-20T10:19:24.194828+01:00 I t2 [182007::backup_user_db-0] sql_commands.cc:289 backup complete

Looking into the debug file for the time when the "syslog_copy" table was created I could not find anything in particular.

In the ".schema" view, I can see the two "lnav" databases:

ATTACH DATABASE '' AS 'main';
ATTACH DATABASE '' AS 'lnav_db'

However regarding the user table, the create command does not indicate the DB it should be created into (don't know if it should):

CREATE TABLE syslog_copy(
  log_line INT,
  log_time NUM,
  log_level TEXT,
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions