Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\dt unexpectedly lists SQLite system tables #504

Open
sigoden opened this issue Dec 13, 2024 · 1 comment
Open

\dt unexpectedly lists SQLite system tables #504

sigoden opened this issue Dec 13, 2024 · 1 comment

Comments

@sigoden
Copy link

sigoden commented Dec 13, 2024

In sqlite, \dt is intended to list only user-created tables, but it also includes system tables.

Steps to produce

1. prepare a test.db

Create a test.sql file

create table test (test_id int, name string);
insert into test (test_id, name) values (1, 'hello');

Execute the sql file

usql sqlite3://test.db -f test.sql

2. run \dt on the test.db

$ usql sqlite3://test.db -c '\dt'
             List of relations
 Schema |        Name        |     Type     
--------+--------------------+--------------
        | fts3               | SYSTEM TABLE 
        | fts3tokenize       | SYSTEM TABLE 
        | fts4               | SYSTEM TABLE 
        | fts4aux            | SYSTEM TABLE 
        | fts5               | SYSTEM TABLE 
        | fts5vocab          | SYSTEM TABLE 
        | json_each          | SYSTEM TABLE 
        | json_tree          | SYSTEM TABLE 
        | pragma_module_list | SYSTEM TABLE 
        | rtree              | SYSTEM TABLE 
        | rtree_i32          | SYSTEM TABLE 
        | test               | TABLE 
(12 rows)

Additional Context

$ usql --version
usql 0.19.14
@nineinchnick
Copy link
Member

Looks like we're missing a default filter: https://github.com/xo/usql/blob/master/drivers/sqlite3/sqshared/reader.go#L127
We include all system tables in the subquery there, and filter them out later, to avoid more complex logic around building the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants