Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server requires mixed mode when BACKUP is used as a column name #3129

Closed
rchurchley opened this issue Mar 30, 2021 · 1 comment
Closed
Assignees
Milestone

Comments

@rchurchley
Copy link

Which version and edition of Flyway are you using?

Flyway Community Edition 7.7.1 by Redgate

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command line

Which database are you using? (Type & version)

Microsoft SQL Server 15.0 (2019) on Docker

Which operating system are you using?

Docker container based on RHEL.

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

Run the following script through flyway, with -mixed="false":

CREATE OR ALTER PROCEDURE [dbo].[FOO] AS SELECT 1 AS [BACKUP]
GO

CREATE OR ALTER PROCEDURE [dbo].[BAR] AS SELECT 1 AS [NOT_BACKUP]
GO
What did you expect to see?

The script should successfully be run, with both procedures generated.

If this is not possible, the limitation should be documented at https://flywaydb.org/documentation/knownparserlimitations.

What did you see instead?
ERROR: Detected both transactional and non-transactional statements within the same migration (even though mixed is false). Offending statement found at line 4: CREATE OR ALTER PROCEDURE [dbo].[BAR] AS SELECT 1 AS [NOT_BACKUP]

The parser appears to catch the column name BACKUP in a filter intended for the non-transactional statements BACKUP DATABASE or BACKUP LOG. The parser does not make the same mistake when BACKUP is a proper substring of the column name, so the second create procedure is correctly interpreted as a transactional statement.

@rchurchley rchurchley changed the title Misleading error message in SQL Server when BACKUP is used as a column name SQL Server requires mixed mode when BACKUP is used as a column name Mar 31, 2021
@Rixium
Copy link
Contributor

Rixium commented Apr 1, 2021

Hey @rchurchley ,

Thanks for finding and reporting this issue,
I've managed to reproduce the bug, and it does seem to be a limitation with our parser, at the moment,
which we'll aim to fix, hopefully in the next release,

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants