[bug_fixed] ZSqlUpdate append error

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

Post Reply
barko
Senior Boarder
Senior Boarder
Posts: 51
Joined: 07.09.2005, 13:13

[bug_fixed] ZSqlUpdate append error

Post by barko »

After svn revision 65 there is an error if you use ZSqlUpdate for appending data to firebird database on lazarus for windows and linux (latest lazarus from svn and latest fpc 2.0.3 from svn)

If you downgrade to svn rev. 65 (testing branch) and try test project (link removed), you will see no error, but if you upgrade to latest svn or to svn rev. 66 and up, there is an error when you append data to firebird database. (in test project for lazarus is sample database included)

i'm testing on firebird 1.5 for windows and linux

my english sux, sorry... :)

p.s. error is access violation

line 651 is here:

Code: Select all

procedure TZUpdateSQL.CalculateDefaults(Sender: IZCachedResultSet;
  RowAccessor: TZRowAccessor);
begin
 {BEGIN PATCH [1214009] TZUpdateSQL - implemented feature to Calculate default values}
 Sender.GetNativeResolver.CalculateDefaults(Sender, RowAccessor); // this is 651 line (see backtrace for more infos)
 {END PATCH [1214009] TZUpdateSQL - implemented feature to Calculate default values}
end;
p.s. 2

I have tested your suggestion (fduenas), but result is same...

Here is my diff:

Code: Select all

Index: zeos/branches/testing/src/dbc/ZDbcInterbase6.pas
===================================================================
--- zeos/branches/testing/src/dbc/ZDbcInterbase6.pas    (revision 86) 
+++ zeos/branches/testing/src/dbc/ZDbcInterbase6.pas    (working copy) 
@@ -46,7 +46,7 @@
   Types,
 {$ENDIF}
   ZCompatibility, Classes, SysUtils, ZDbcUtils, ZDbcIntfs, ZDbcConnection,
-  Contnrs, ZPlainInterbaseDriver, ZPlainFirebirdDriver, 
+  Contnrs, ZPlainInterbaseDriver, ZPlainFirebirdDriver, ZDbcCachedResultSet, 
   ZPlainFirebirdInterbaseConstants, ZSysUtils, ZDbcInterbase6Utils, ZDbcLogging,
   ZDbcGenericResolver, ZTokenizer, ZGenericSqlAnalyser;
 
@@ -128,7 +128,7 @@
   end;
 
   {** Implements a specialized cached resolver for Interbase/Firebird. }
-  TZInterbase6CachedResolver = class(TZGenericCachedResolver) 
+  TZInterbase6CachedResolver = class(TZGenericCachedResolver, IZCachedResolver) 
   public
     function FormCalculateStatement(Columns: TObjectList): string; override;
   end;
Fixed. Thanks! :)
Last edited by barko on 02.08.2006, 15:00, edited 6 times in total.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Thanks Barko,
I'll add the backtrace you've sent me before:
barko wrote:Hi, sorry to bother you again... :) here is my backtrace (gdb) from my test project (i send you test project before)... problem starts in ZSqlUpdate.pas in line 651... fyi: if I comment this line, it's work ok, ... :)

Code: Select all

#0  0x081f27c4 in TZUPDATESQL__CALCULATEDEFAULTS (
    SENDER={<IZRESULTSET> = {<IUNKNOWN> = {}, }, }, ROWACCESSOR=0xb7ae0468,
    this=0xb792a1a8) at ZSqlUpdate.pas:651
#1  0x0824622a in TZABSTRACTCACHEDRESULTSET__CALCULATEROWDEFAULTS (
    ROWACCESSOR=0xb7ae0468, this=0xb7ad71a8) at ZDbcCachedResultSet.pas:403
#2  0x082464c8 in TZABSTRACTCACHEDRESULTSET__POSTUPDATES (this=0xb7ad71a8)
    at ZDbcCachedResultSet.pas:518
#3  0x0824773f in TZABSTRACTCACHEDRESULTSET__INSERTROW (this=0xb7ad71a8)
    at ZDbcCachedResultSet.pas:1495
#4  0x082cf78c in TZABSTRACTDATASET__INTERNALADDRECORD (BUFFER=0xb7933348,
    APPEND=false, this=0xb78c2a78) at ZAbstractDataset.pas:382
#5  0x082cfa2c in TZABSTRACTDATASET__INTERNALPOST (this=0xb78c2a78)
    at ZAbstractDataset.pas:431
#6  0x081ff8fe in DB_TDATASET_$__TRYDOING$TDATAOPERATION$TDATASETERROREVENT$$BOO
LEAN ()
#7  0x081ff3ef in DB_TDATASET_$__POST ()
#8  0x0807876d in TFORM1__BUTTON3CLICK (SENDER=0xb78dd2c8, this=0xb78d97a8)
    at unit1.pas:67
#9  0x0810e536 in TCONTROL__CLICK (this=0xb78dd2c8) at control.inc:1876
#10 0x0816109d in TBUTTONCONTROL__CLICK (this=0xb78dd2c8)
    at buttoncontrol.inc:57
#11 0x08162af1 in TCUSTOMBUTTON__CLICK (this=0xb78dd2c8) at buttons.inc:187
#12 0x08162ebd in TBUTTON__CLICK (this=0xb78dd2c8) at buttons.inc:298
---Type <return> to continue, or q <return> to quit---
#13 0x08162cb8 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE=
      {MSG = 1031, WPARAM = 138975432, LPARAM = -1209851612, RESULT = 138975432,
 WPARAMLO = 39112, WPARAMHI = 2120, LPARAMLO = 8484, LPARAMHI = 47075, RESULTLO
= 39112, RESULTHI = 2120}, this=0xb78dd2c8) at buttons.inc:242
#14 0x0805e220 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
#15 0x0810de3e in TCONTROL__WNDPROC (THEMESSAGE=
      {MSG = 1031, WPARAM = 138975432, LPARAM = -1209851612, RESULT = 138975432,
 WPARAMLO = 39112, WPARAMHI = 2120, LPARAMLO = 8484, LPARAMHI = 47075, RESULTLO
= 39112, RESULTHI = 2120}, this=0xb78dd2c8) at control.inc:1553
#16 0x08105889 in TWINCONTROL__WNDPROC (MESSAGE=
      {MSG = 1031, WPARAM = 138975432, LPARAM = -1209851612, RESULT = 138975432,
 WPARAMLO = 39112, WPARAMHI = 2120, LPARAMLO = 8484, LPARAMHI = 47075, RESULTLO                          = 39112, RESULTHI = 2120}, this=0xb78dd2c8) at wincontrol.inc:3399
#17 0x08123d75 in DELIVERMESSAGE (TARGET=0xb78dd2c8, AMESSAGE=void)
    at gtkproc.inc:3514
#18 0x081bfbec in GTKWSBUTTON_CLICKED (AWIDGET=0x8489168, AINFO=0xb7ab79d8)
    at gtkwsbuttons.pp:118
#19 0xb7d8eed6 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0
#20 0x08489168 in ?? ()
#21 0xb7ab79d8 in ?? ()
#22 0xb7e32124 in ?? () from /usr/lib/libgtk-1.2.so.0
#23 0xb7dc62dd in gtk_signal_connect_while_alive ()
   from /usr/lib/libgtk-1.2.so.0
---Type <return> to continue, or q <return> to quit---
#24 0x08489168 in ?? ()
#25 0x081bfbbc in GTKWSARROW_init () at gtkwsarrow.pp:91
#26 0x0000ad15 in ?? ()
#27 0x08489060 in ?? ()
#28 0x00000158 in ?? ()
#29 0xb7d8eec0 in gtk_marshal_NONE__INT_INT_POINTER ()
   from /usr/lib/libgtk-1.2.so.0
#30 0x00000001 in ?? ()
#31 0x00000009 in ?? ()
#32 0x00000000 in ?? ()
To Fduenas,

Can you please have a look at this. I don't know if you use firebird, but might there be something you forgot when implementing the 'autoincrement fields for mysql patch'?

Mark
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Hi Barko, what is exactly the error? and plz send the the line of that you commented.

Thanks
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

Hi I have check the issue. But this is somethign to do with a coding bug.

Almost al drivers implement the IZCachedResolver interface in their own TZXXXXCachedResolver class (Check ZMySQLResultSet.pas or ZAdoResultSet.pas), all except for Interbase, the TZInterbase6CachedResolver is declared wrongly as (check ZDbcInterbase6.pas):

Code: Select all

TZInterbase6CachedResolver = class(TZGenericCachedResolver)
And should be

Code: Select all

TZInterbase6CachedResolver = class(TZGenericCachedResolver, IZCachedResolver)
I think that's why it gives the error.

Also i think the TZInterbase6CachedResolver declaration should be moved from ZInterbase6.pas to ZInterbase6Resulset.pas, coz all other drivers declare their cached resolver class in their respective ZXXXXResulset.pas file.
User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Post by fduenas »

I think i have found the error.
It has to be with a function GetCachedResulset located at ZDBCInterbase6Utils.pas,
when the CachedResultset is created, the param for the NativeResolver is set as Nil, thats why it gives the problem. so the function

Code: Select all

function GetCachedResultSet(SQL: string;
  Statement: IZStatement; NativeResultSet: IZResultSet): IZResultSet;
var
  CachedResultSet: TZCachedResultSet;
begin
  if (Statement.GetResultSetConcurrency <> rcReadOnly)
    or (Statement.GetResultSetType <> rtForwardOnly) then
  begin
    CachedResultSet := TZCachedResultSet.Create(NativeResultSet, SQL, nil);
    CachedResultSet.SetResolver(TZInterbase6CachedResolver.Create(
      Statement,  NativeResultSet.GetMetadata));
    CachedResultSet.SetConcurrency(Statement.GetResultSetConcurrency);
    Result := CachedResultSet;
  end else
    Result := NativeResultSet;
end;
Should be like this

Code: Select all

function GetCachedResultSet(SQL: string;
  Statement: IZStatement; NativeResultSet: IZResultSet): IZResultSet;
var
  CachedResolver: TZInterbase6CachedResolver;
  CachedResultSet: TZCachedResultSet;
begin
  if (Statement.GetResultSetConcurrency <> rcReadOnly)
    or (Statement.GetResultSetType <> rtForwardOnly) then
  begin
    CachedResolver  := TZInterbase6CachedResolver.Create(
      Statement,  NativeResultSet.GetMetadata);
    CachedResultSet := TZCachedResultSet.Create(NativeResultSet, SQL,
      CachedResolver);
    CachedResultSet.SetConcurrency(Statement.GetResultSetConcurrency);
    Result := CachedResultSet;
  end else
    Result := NativeResultSet;
end;
This should do the work.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi, I applied the patch by fduenas to revision 90 of SVN testing branch.
Barko, can you confirm it's fixed? Eventually you can edit your initial post and add '[ bug_fixed ]' (without spaces) to the subject.

Mark
Post Reply