You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mssql): fix temporary table creation and implement cache
MSSQL has two kinds of temporary tables.
1. Local temporary tables, created in `tempdb.dbo`, prefixed with a
single `#` and suffixed with ~~112 underscores and a number.
2. Global temporary tables, created in `tempdb.dbo`, and prefixed with a
double `#`.
The suffixing on local temporary tables is to avoid name collisions
between separate user sessions trying to create the same temporary table
name.
Otherwise, the two types of temporary tables are functionally
equivalent. Users need specific access to look at temporary tables that
they didn't create, and all temp tables are cleaned up after the session
closes and all stored procedures referencing those tables have run.
Because of the slightly wacky semantics of local temporary tables, this
PR makes all temp tables created by the MSSQL backend "global". This
makes the names much more predictable.
A user creating a temporary table with the name "hithere", will find
that there is no table called "hithere" in the output of
`con.list_tables()`. Instead, they will find a table called "##hithere"
if they run `con.list_tables(database=("tempdb", "dbo"))`.
The returned table reference from the `create_table` call works the same
as any other table reference, and you can create persistent tables from
temporary tables. The only major hiccough is the perpending of the `##`
on the table name, but that is the behavior of MSSQL.
I've also added in support for passing in explicit `catalog` and
`database` to `create_table`, which was missing (I believe this was an
oversight, since MSSQL definitely supports this).
0 commit comments