TMSQuery.Open corrupts memory

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Saupg
Posts: 19
Joined: Wed 05 Nov 2008 11:53

TMSQuery.Open corrupts memory

Post by Saupg » Mon 05 May 2014 13:46

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!

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery.Open corrupts memory

Post by azyk » Tue 06 May 2014 14:38

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.

Saupg
Posts: 19
Joined: Wed 05 Nov 2008 11:53

Re: TMSQuery.Open corrupts memory

Post by Saupg » Wed 07 May 2014 05:50

It's great, thank you!!!

ismet
Posts: 6
Joined: Thu 11 Nov 2004 08:47
Location: Antalya, TURKIYE

Re: TMSQuery.Open corrupts memory

Post by ismet » Wed 07 May 2014 13:17

Hi,
I also have this problem. When it is published?
Thanks,
Ismet Celebi

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery.Open corrupts memory

Post by azyk » Wed 07 May 2014 13:34

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.

ismet
Posts: 6
Joined: Thu 11 Nov 2004 08:47
Location: Antalya, TURKIYE

Re: TMSQuery.Open corrupts memory

Post by ismet » Wed 07 May 2014 15:55

Hi Andrey,
I sent information
Thanks a lot.
Ismet

ismet
Posts: 6
Joined: Thu 11 Nov 2004 08:47
Location: Antalya, TURKIYE

Re: TMSQuery.Open corrupts memory

Post by ismet » Mon 12 May 2014 13:09

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

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery.Open corrupts memory

Post by azyk » Thu 15 May 2014 15:28

Hi,

We sent a custom build to your email.

Post Reply