The following problems have been discovered in the SQL procedure QBM_PColumnCustomRemove:
1.)
The general structure of the procedure is:
BEGIN TRY
... do some tests and collect errors
If there were any errors: Throw an exception
BEGIN TRANSACTION
... process the column deletion
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK
END CATCH
If the tests in the beginning find an error, an exception is thrown and the CATCH block is executed.
The ROLLBACK leads to an error, because in this situation no TRANSACTION has been started:
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
Additionally the error message, which was collected in the tests, is not displayed.
2.)
The test "Checking template references" identifies an error if the column to be deleted has a template with a reference to itself.
The column to be deleted must be excluded from this test.
3.)
Regarding the test "Checking indexes":
If the column to be deleted is a foreign key column, a generated index exists which includes that column.
But in this case the collected repair statement is empty.
Cause: The repair statement is concatenated from different strings.
One of them is the result of "dbo.QBM_FSQIndexDef(t.name, i.name)".
That function returns NULL in case of a generated index. And therefore the complete concatenated string is also NULL.
Apart from that check should not fail if the column is contained in a generated index.
Because after the column deletion the generated indexes will be recalculated.