DacFx icon indicating copy to clipboard operation
DacFx copied to clipboard

Incorrect deployment plan order generated when a table valued function with schema binding is dependent on Temporal table

Open sejagada opened this issue 1 year ago • 0 comments

  • DacFx Version: 162.3.564
  • Tested in SSMS latest version

You can reproduce the issue in the one of the 2 ways:

  1. Steps to Reproduce using WideWorldImporters Database:

    i. Install SQL Server 2022 & import WideWorldImporters database. ii. Right click on 'Application.Cities' -> Encrypt columns -> Select City Name -> New Encryption key -> Go to Summary & finish. Encryption fails with the below error. image (4)

  2. Steps to Reproduce by creating tables i. Install SQL Server 2022 & connect to it using SSMS. ii. Create a new database & create a temporal table as below:

      CREATE TABLE Department
       (
           DeptID INT NOT NULL PRIMARY KEY CLUSTERED,
           DeptName VARCHAR(50) NOT NULL,
           ManagerID INT NULL,
           ParentDeptID INT NULL,
           ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL,
           ValidTo DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL,
           PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
       )
       WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.DepartmentHistory));
iii. Create a table-valued function with schema binding as below:
    CREATE FUNCTION Test(@ManagerID int)  
        RETURNS TABLE  
        WITH SCHEMABINDING
        AS  
        RETURN  
            SELECT ParentDeptID  
            FROM dbo.Department  
            WHERE ManagerID > @ManagerID

iv. Right click on the table -> Encrypt columns -> Select DeptName -> New Encryption key -> Go to Summary & finish. Encryption fails with the same error as above.

DetermineCustomerAccess is a table value function with schema binding which depends on the temporal table Application.Cities. During the deployment, drop system-versioning step is being executed before schema unbinding step due to which the exception is thrown.

sejagada avatar Jun 07 '24 12:06 sejagada