Page 1 of 1

TMSQuery.Open corrupts memory

Posted: Mon 05 May 2014 13:46
by Saupg
Hello!

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)
Table for test query must have more then 1 column and primary key with more than 1 column:

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 use TMSConnection and TMSQuery with default properties.
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;
With this query i have error: "Exception class EOLEDBError with message 'Ошибка протокола в потоке TDS'.".

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!

Re: TMSQuery.Open corrupts memory

Posted: Tue 06 May 2014 14:38
by azyk
Thank you for the information. We have reproduced the problem with access violation and fixed it.
To return the old behavior, you should set the TMSQuery.Options.UniqueRecords option to False.

Re: TMSQuery.Open corrupts memory

Posted: Wed 07 May 2014 05:50
by Saupg
It's great, thank you!!!

Re: TMSQuery.Open corrupts memory

Posted: Wed 07 May 2014 13:17
by ismet
Hi,
I also have this problem. When it is published?
Thanks,
Ismet Celebi

Re: TMSQuery.Open corrupts memory

Posted: Wed 07 May 2014 13:34
by azyk
Hi,

If you want to get this fix, provide your e-mail address and license number to andreyz*devart*com and we will send you a custom build.

Re: TMSQuery.Open corrupts memory

Posted: Wed 07 May 2014 15:55
by ismet
Hi Andrey,
I sent information
Thanks a lot.
Ismet

Re: TMSQuery.Open corrupts memory

Posted: Mon 12 May 2014 13:09
by ismet
Hi,
Recently I sent you my license information.
But you still have not sent me acustom build.

Can you send me?

Thanks a lot.

Ismet Celebi

Re: TMSQuery.Open corrupts memory

Posted: Thu 15 May 2014 15:28
by azyk
Hi,

We sent a custom build to your email.