Repository navigation
Description
Problem
A temporary table created in a session does not appear in the sidebar, so after CREATE TEMPORARY TABLE there is no way to browse it, see its structure, or open it in a tab. It only exists in whatever query the user types next.
Listing it is not just a missing query. A temporary table belongs to the session that made it, and the sidebar reads through DatabaseManager.withMetadataDriver (apple/TablePro/Core/Database/DatabaseManager+Metadata.swift:48), which on an engine that pools connections, the default (apple/TablePro/Core/Plugins/PluginMetadataRegistry.swift:78), is a different connection from the query tab's session. That connection cannot see the table at all.
Proposed solution
- A Temporary section in the sidebar, present only while the session holds at least one, listing the temporary tables of the session the query tabs run on.
- Read on that session, never on a metadata connection:
- PostgreSQL: the session's own temporary schema,
pg_my_temp_schema(). - SQLite:
sqlite_temp_schema. - SQL Server:
tempdb.sys.tables, filtered to the local temporary tables this session owns. - MySQL and MariaDB: the names from the
CREATE TEMPORARY TABLEandDROP TEMPORARY TABLEstatements the session ran. The driver already reads statement text for temporary tables (apple/Plugins/MySQLDriverPlugin/MySQLSessionFootprint.swift:34), because the server offers no list an ordinary user can read:INNODB_TEMP_TABLE_INFOrefuses a user without PROCESS (error 1227, measured in that file's comment) and reports internal#sqlnames anyway.
- PostgreSQL: the session's own temporary schema,
- Open, browse and show the structure of one like any other table, on the same session.
- Refresh the section after a statement that creates or drops one, and clear it when the session ends, since the tables go with it.
Done means CREATE TEMPORARY TABLE t AS SELECT 1 AS x in a query tab on PostgreSQL, MySQL, SQL Server or SQLite puts t under Temporary, and opening it shows its one row.
Alternatives considered
SELECT * FROM the name you just typed.
Platform
macOS
Related database type
N/A / General
Activity