microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.52k stars 893 forks source link

SQLCMD mode doesn't stop processing even when set :on error exit #7851

Open Colizobble opened 4 years ago

Colizobble commented 4 years ago

Issue Type: Bug

In SQLCMD mode, if the line :on error exit is included in the script, the expected behaviour is that the batch will stop processing on the first error. This does not happen with files submitted through Azure Data Studio.

Script that reproduces problem:

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

GO
:on error exit
GO
/*
Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
To re-enable the script after enabling SQLCMD mode, execute the following:
SET NOEXEC OFF; 
*/
:setvar __IsSqlCmdEnabled "True"
GO
IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
    BEGIN
        PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
        SET NOEXEC ON;
    END

GO
USE [master];
GO
PRINT 'Generate error'
GO
SELECT 0/0
GO
PRINT 'Should not get here'
GO

Azure Data Studio version: Azure Data Studio 1.12.2 (c9bef82ace6c67190d0e83820011a2bbd1f793c1, 2019-10-11T04:05:05.798Z) OS version: Darwin x64 18.7.0

udeeshagautam commented 4 years ago

Validated that it gives the error : Command OnError is not supported and does not execute further.

Moving to Planning Milestone and relating to https://github.com/microsoft/azuredatastudio/issues/7381 for further handling