7.0.5 TZMySQLPreparedResultSet.GetLong problem

The stable tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.
Alfa000
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: 05.12.2012, 09:09

7.0.5 TZMySQLPreparedResultSet.GetLong problem

Postby Alfa000 » 09.09.2013, 21:21

Hello.

Next code pretty show bug...
Normal IZStatement (MySQL) works well but IZPreparedStatement (MySQL) don't.

Code: Select all

var
  LStat: IZStatement;
  LPrepStat: IZPreparedStatement;
  LRS: IZResultSet;
  sTableQuery: string;
  ZVariant: TZVariant;
  LInfo: TStringList;
  sConString: string;
  LZeos: IZConnection;
begin
  sConString := Format('zdbc:%s://%s:%d/%s?UID=%s;PWD=%s', ['mysql-5', '127.0.0.1', 4434, 'aslibex_dunit_zeos', 'root', '']);

  LZeos := DriverManager.GetConnection(sConString);

  sTableQuery :=  'CREATE TABLE Error_test ('+
                  '  IntField INT'+
                  ')'+
                  'COLLATE=''utf8_general_ci''' + #13#10 +
                  'ENGINE=InnoDB';

  LStat := LZeos.CreateStatement;

  //Create table
  LStat.ExecuteUpdate(sTableQuery);

  //Insert two rows with values 5 and -5.
  Check(
    LStat.ExecuteUpdate('INSERT INTO Error_test (IntField) VALUES (5);') = 1);
  Check(
    LStat.ExecuteUpdate('INSERT INTO Error_test (IntField) VALUES (-5);') = 1);

  LRS := LStat.ExecuteQuery('SELECT * FROM Error_test');

  //Get first row with value 5
  Check(LRS.Next);
  ZVariant := LRS.GetValueByName('IntField');
  if ZVariant.VInteger <> 5 then
    raise Exception.Create('Error');

  //Get second row with value -5
  Check(LRS.Next);
  ZVariant := LRS.GetValueByName('IntField');
  if ZVariant.VInteger <> -5 then
    raise Exception.Create('Error');

  LRS := nil;
  LStat := nil;

  /// Now i use PreparedStatement!
  ////////////////////////////////

  LInfo := TStringList.Create;
  LInfo.Add('preferprepared=true');

  LPrepStat := LZeos.PrepareStatementWithParams('SELECT * FROM Error_test;', LInfo);
  LRS := LPrepStat.ExecuteQueryPrepared;

  //Get first row with value 5
  Check(LRS.Next);
  ZVariant := LRS.GetValueByName('IntField');
  if ZVariant.VInteger <> 5 then
    raise Exception.Create('Error');

  //Get second row with value -5
  Check(LRS.Next);
  ZVariant := LRS.GetValueByName('IntField');
  if ZVariant.VInteger <> -5 then
    raise Exception.Create('Error'); //<<<< this error occurs !!! !!! !!!

  LRS := nil;
  LPrepStat := nil;
  LInfo.Free;
end;


I try fix this error and i replace original metod:

Code: Select all

function TZMySQLPreparedResultSet.GetLong(ColumnIndex: Integer): Int64;
var
  full64, bitmask: Int64;
Begin
{$IFNDEF DISABLE_CHECKING}
  CheckColumnConvertion(ColumnIndex, stLong);
{$ENDIF}
 full64 := bufferasInt64(ColumnIndex);
 bitmask := $FFFFFFFF;
 Result := Int64(full64 and bitmask);
 LastWasNull := FColumnArray[ColumnIndex-1].is_null =1;
end;


with this code

Code: Select all

function TZMySQLPreparedResultSet.GetLong(ColumnIndex: Integer): Int64;
var
  full64, bitmask: Int64;
Begin
{$IFNDEF DISABLE_CHECKING}
  CheckColumnConvertion(ColumnIndex, stLong);
{$ENDIF}
 Result := bufferasInt64(ColumnIndex); //Dak_alpha
 LastWasNull := FColumnArray[ColumnIndex-1].is_null =1;
end;


I don't know if this is good solution, but works for me. I suggest that bug occur for TZMySQLPreparedResultSet. In normal TZMySQLResultSet all works well. I don't test another DBs.

Sorry for me poor English.
Daniel Andrascik

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Re: 7.0.5 TZMySQLPreparedResultSet.GetLong problem

Postby EgonHugeist » 10.09.2013, 19:33

Patch done R2723 \testing-7.1 (SVN)

Can't see other issues after commenting the bitmasks..
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image


Return to “ZeosLib 7.0 Stable Forum”

Who is online

Users browsing this forum: No registered users and 1 guest