Skip to content

Prevent temporary table name collisions#10357

Merged
angelamayxie merged 9 commits intomainfrom
angela/temptables
Jan 23, 2026
Merged

Prevent temporary table name collisions#10357
angelamayxie merged 9 commits intomainfrom
angela/temptables

Conversation

@angelamayxie
Copy link
Copy Markdown
Contributor

@angelamayxie angelamayxie commented Jan 22, 2026

fixes #10353

MySQL allows creating temporary tables with the same names as existing non-temporary tables and creating non-temporary tables with the same names as existing temporary tables. However, temporary tables cannot have the same name as other temporary tables.

Our previous implementation seemed to have assumed temporary tables with the same names were allowed. Each session had a map of db names to an array of tables, and new temporary tables were added to the end of the array, without checking if there was a table with an existing name. When fetching or dropping a temporary table, we iterated through the array and returned/dropped the first table with a matching name; this meant even though we allowed temporary tables with the same name, we only ever operated on whichever one was created first.

Since temporary tables with the same names are actually not allowed, the array of temporary tables was replaced with a name-to-table map to make fetching a temporary table with GetTemporaryTable faster. This also makes DropTemporaryTable faster. This does make GetAllTemporaryTables slower since we now have to iterate over the mappings to create an array for temporary tables, but GetAllTemporaryTables doesn't seem to be called as frequently as GetTemporaryTable.

@coffeegoddd
Copy link
Copy Markdown
Contributor

@angelamayxie DOLT

comparing_percentages
100.000000 to 100.000000
version result total
1af6306 ok 5937471
version total_tests
1af6306 5937471
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@angelamayxie DOLT

comparing_percentages
100.000000 to 100.000000
version result total
06b3991 ok 5937471
version total_tests
06b3991 5937471
correctness_percentage
100.0

@angelamayxie angelamayxie requested a review from jycor January 23, 2026 00:05
@angelamayxie angelamayxie marked this pull request as ready for review January 23, 2026 00:05
Copy link
Copy Markdown
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@angelamayxie angelamayxie merged commit 2ee439e into main Jan 23, 2026
24 of 26 checks passed
@angelamayxie angelamayxie deleted the angela/temptables branch January 23, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dolt needs to error out when creating duplicate temporary table.

3 participants