dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.58k stars 498 forks source link

Creating temporary tables can cause tag collisions #7995

Closed arvidfm closed 2 months ago

arvidfm commented 2 months ago

Temporary tables simply use the column index as the column tag, so if you're very unlucky you can end up with a tag collision if a non-temporary table with the same tag already exists.

The below MWE always results in the error ERROR 1105 (HY000): cannot create column g on table tmp_tbl, the tag 6 was already used in table note:

DROP TABLE IF EXISTS note, tmp_tbl;

CREATE TABLE note(a int, b int, userid int);
CREATE TEMPORARY TABLE tmp_tbl(a int, b int, c int, d int, e int, f int, g int);

DROP TABLE note;
timsehn commented 2 months ago

I hate tags. Good find.

jycor commented 2 months ago

Hey @arvidfm nice find!

We made a change that has temporary tables use the same tag generating logic as persisting tables. It does fix this particular collision, and will probably make future collisions more unlikely, probably.