MySQL: User-defined variables leak across migrations #2197
Which version and edition of Flyway are you using?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
flyway commandline 5.2.1
Which database are you using (type & version)?
Which operating system are you using?
What did you do?
Create two migrations with different variables in them, noticing the variable leak with a typo in the second migration:
What did you expect to see?
Not having access to
What did you see instead?
The second migration V2 fails only if migrated without V1 (
The text was updated successfully, but these errors were encountered:
Digging deeper into this, it appears that starting with MySQL 5.7 the following should be possible:
This should effectively plug this leak.
Hmm looks like that table is not enabled per default:
Anyway, I thought flyway's parser would analyze the SQL statements figuring variables and reset them or at least reset the session to a consistent state across the migrations.
If this behavior is to be expected, it might be useful to state this in the documentation.
For MariaDB 10.2 and later it appears the query should be replaced with
The fix for this will therefore only be implemented by default for MariaDB 10.2+ and MySQL 5.7+.
For earlier MariaDB versions, the existence of this table should first be checked with