I try to upgrade my project from SDAC v5 to newest version (6.10).
I have very many strange exceptions about "Communication link failure", "... wrong TDS protocol ...", "... wrong format ..." and various "access violations" after it. Sometimes process freezes.
I try to debug this problem and found that "TMSQuery.Open" corrupts memory for some big SQL-queries (with using "Common table expressions", "OUTER\CROSS APPLY" and many joins).
And i can reproduce this problem in small projects!
I use Delphi XE and SQL Server 2005 SP4:
Code: Select all
Microsoft SQL Server 2005 - 9.00.5292.00 (X64)
Apr 13 2011 15:43:31
Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
Code: Select all
CREATE TABLE [dbo].[SDAC_BUG](
ID SMALLINT NOT NULL,
ID_PARENT SMALLINT NOT NULL
CONSTRAINT [PK_SDAC_BUG] PRIMARY KEY (ID, ID_PARENT)
)I spent a lot of time to find a simple query for example:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
const
qTest =
'WITH TEST (ID) AS ( ' +
' SELECT A.ID FROM SDAC_BUG A ' +
' LEFT JOIN SDAC_BUG B ON 1 = 2 ' +
') ' +
'SELECT T.ID FROM SYS.OBJECTS GP ' +
'LEFT JOIN TEST T ON 1 = 2';
begin
MSConnection1.Open;
MSQuery1.SQL.Text := qTest;
MSQuery1.Open; // <--- Exception!
MSConnection1.Close;
end;If i change "LEFT JOIN" to "FULL JOIN" in last row, i have error: "Exception class EOLEDBError with message 'Соединение больше нельзя использовать, так как ответ сервера на выполнявшуюся ранее инструкцию имел неправильный формат.'".
If i change it to "INNER JOIN" or create table's primary key only for one column - i haven't any errors.
Please help!