Alignment BUG

torsten.strausstorsten.strauss Posts: 271 Silver 3
edited December 31, 2018 1:19PM in SQL Prompt
Hi!

The following statement is formatted like this:
[code]
-- Start the session io_reads
IF NOT EXISTS
    (
        SELECT *
        FROM
            sys.dm_xe_sessions
        WHERE
            name = N'io_reads'
    )
    ALTER EVENT SESSION io_reads
    ON SERVER STATE = START;
    GO

    -- Watch event session

    -- Execute with a non selective value : 0
    -- Actual number of rows : 9994
    -- Estimated number of rows : 100 ?
    -- SQL Server cannot expand the multi statement table valued function
    -- No use of statistic cause of the use of a table variable in the multi statement
    -- table value function
    -- Tabled variables do not have any statistics
    -- Table '#A98990E0'. Scan count 1, logical reads 21
    -- Event session : logical_reads    11412
    SELECT *
    FROM
        mtvf_statisitc(0)
    ;
    GO

    -- Stop the session
    IF NOT EXISTS
        (
            SELECT
                *
            FROM
                sys.dm_xe_sessions
            WHERE
                name = N'io_reads'
        )
        ALTER EVENT SESSION io_reads
        ON SERVER STATE = STOP;
GO
[/code]

The issues start with the first GO which is not aligned. Therefore it seems that the entire code is sent one tab to the right.
I have even examples here where this bug is cascading which ends up with code which is ten tabs to the right.

BTW It took me one hour to reformat my code because the only solution seems to highlight every batch one by one and format...

Please fix this bug- thanks!

Torsten
MVP
SQL Prompt Version 9.4.6.7396


Answers

  • Its hard to work out quite what you're wanting to see here Torsten. I get


    You're saying this is not what you want?
    Have you visited our Help Centre?
  • Hi Russell  
    Thanks for looking into this! 
    The issue is that the statement after the GO is shift one tab to the right.
    If you format the batches one by one you will see that the tab is gone correctly  
    This behaviour leads to a formatted code which will be shifted to the right after each GO (or for other reasons) 
    In the end your entire code is completely out of alignment  
  • Here we go

    -- Start the session io_reads
    IF NOT EXISTS
        (
            SELECT *
            FROM
                sys.dm_xe_sessions
            WHERE
                name = N'io_reads'
        )
        ALTER EVENT SESSION io_reads
        ON SERVER STATE = START;
        GO

        -- Start the session io_reads
        IF NOT EXISTS
            (
                SELECT *
                FROM
                    sys.dm_xe_sessions
                WHERE
                    name = N'io_reads'
            )
            ALTER EVENT SESSION io_reads
            ON SERVER STATE = START;
            GO

            -- Start the session io_reads
            IF NOT EXISTS
                (
                    SELECT *
                    FROM
                        sys.dm_xe_sessions
                    WHERE
                        name = N'io_reads'
                )
                ALTER EVENT SESSION io_reads
                ON SERVER STATE = START;
                GO

                -- Start the session io_reads
                IF NOT EXISTS
                    (
                        SELECT *
                        FROM
                            sys.dm_xe_sessions
                        WHERE
                            name = N'io_reads'
                    )
                    ALTER EVENT SESSION io_reads
                    ON SERVER STATE = START;
                    GO

                    -- Start the session io_reads
                    IF NOT EXISTS
                        (
                            SELECT *
                            FROM
                                sys.dm_xe_sessions
                            WHERE
                                name = N'io_reads'
                        )
                        ALTER EVENT SESSION io_reads
                        ON SERVER STATE = START;
                        GO

                        -- Start the session io_reads
                        IF NOT EXISTS
                            (
                                SELECT *
                                FROM
                                    sys.dm_xe_sessions
                                WHERE
                                    name = N'io_reads'
                            )
                            ALTER EVENT SESSION io_reads
                            ON SERVER STATE = START;
    GO

  • Yes, that is odd. I'll dig into it.
    Have you visited our Help Centre?
  • We've logged this as SP-7398 Torsten. I'll update you when I have more information.
    Have you visited our Help Centre?
  • Hi Torsten, this has finally been fixed - if you haven't already updated to the latest version please do so.
    Have you visited our Help Centre?
Sign In or Register to comment.