[bug_fixed] Delphi5 & MySql5

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
brandy
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 27.10.2006, 15:29

[bug_fixed] Delphi5 & MySql5

Post by brandy »

Hi! I'm a new member and I'm no expert in delphi.
I have a problem to install ZEOSDBO-6.6.0-beta on delphi5
I have read some topics on problem install and I've tried to follows the some steps but I've this problem.

I try to compile the:
ZCore --> compiled
ZParseSql --> compiled
ZPlain --> Errors -->

ZPlainPostgreSql8.pas(279):Undeclared identifier: 'PLongword'
the code is:

TPQescapeByteaConn =function(Handle: PPGconn;const from:pchar;from_length:longword;to_lenght:PLongword):PChar;cdecl;

ZDbc --> Same Errors
ZTestFramework --> Same Errors

What can I do ?
Waiting for your help, thank you.

Ila

p.s. Sorry for my english
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Moved to bug forum. Reason is that PLongword did not exist in D5, so we have to declare this otherwise for D5. BTW, Delphi 5 is really old now. If you can move to D7, you better do.
I don't think we will keep supporting it for a long time after next stable release...
Mark
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Here goes the patch:

Code: Select all

Index: ZCompatibility.pas
===================================================================
--- ZCompatibility.pas	(revision 174)
+++ ZCompatibility.pas	(working copy)
@@ -93,6 +93,7 @@
   PCardinal             = ^Cardinal;
   PInt64                = ^Int64;
   PPChar                = ^PChar;
+  PLongWord             = ^LongWord;
 {$ENDIF}
   PWord                 = ^Word;
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Is it that easy?
I'll have to check where I have coded this with ifdefs in the past.
You see... I have no real delphi experience. :mrgreen:
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

hehe! yep, that's easy :)

I forgetted that I have delphi 5 installed. Well, to zeos compile and run on D5, it's needed one thing more.

In ZAbstractRODataset.pas, line 869, there's a call to ApplicationHandleException, defined at D7 in Classes.pas as follows:

ApplicationHandleException: procedure (Sender: TObject) of object = nil;

Yep, an empty procedure. I was not familiar to that procedure, but know that Forms.pas have a Application.HandleException defined. So, looking in forms.pas (D7), at creator of TApplication object, we have:

if not Assigned(Classes.ApplicationHandleException) then
Classes.ApplicationHandleException := HandleException;

Then, the mistery if over :)
What is better, simulate an ApplicationHandleException in ZCompatibility.pas, inside IFDEFs, only for D5 and below, or link ZAbstractRODataset directly to Application.HandleException, in forms.pas?

You decide :D
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
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 gto,

Do you want to take care of this problem? Tell us if you don't. I'll accept your patch ASAP after a compatibility test in D7 and Lazarus.

Please check where I have IFDEFed other pointer variable types for VER130 (grep VER130 shows them all, I think)

I think we better solve this in ZCompatibility whenever possible. Then we can let it die in case we stop supporting D5. Do you use Lazarus as well? Just to make sure this fix does not fail on Lazarus.
See this lines in ZEOS.inc:

Code: Select all

{$IFDEF FPC}
{$DEFINE VER130BELOW}
{$DEFINE VER140BELOW}
{$ENDIF}
Doesn't you fix redeclare PLongWord? Or does that not cause an error?
BTW. Do you know the version naming schedule for fpc? Is there a parallel for VER130, VER140,...
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Well, why not :)

I don't use lazarus/FPC but I'll download it and test, then make the patch.

AFAIK, redeclarations don't cause problems, at least in delphi. The compiler will use the "nearest" declaration it finds. This means if you declare a PLongWord, in the same unit it's used, as a string, it will be a string. If you remove the declaration, it will become a pointer for a long word again.

Lazarus does not use a versioning style, AFAIK (beauty expression :) ), only the FPC.

A bit OFF: Mark, can I post the patch for ZSQLMonitor now? I have it here, done and working for the newest SVN branch.

Little Edit: Looking at source now I've seen something like:

Code: Select all

try
 ...
except
{$IFNDEF VER130BELOW}
      ApplicationHandleException(Self);
{$ENDIF}
end;
This is at ZStreamBlob @ line 107. Isn't the best way to code, but it's a workarround for the problem I've posted up there.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

The patches!!!

Code: Select all

Index: ZAbstractRODataset.pas
===================================================================
--- ZAbstractRODataset.pas	(revision 174)
+++ ZAbstractRODataset.pas	(working copy)
@@ -865,8 +865,12 @@
 
     try
       OnFilterRecord(Self, Result);
-    except
-      ApplicationHandleException(Self);
+    except    
+    {$IFNDEF VER130BELOW}
+        ApplicationHandleException(Self);
+    {$ELSE}
+        ShowException(ExceptObject, ExceptAddr);
+    {$ENDIF}
     end;
 
     CurrentRow := SavedRow;

Code: Select all

Index: ZDbcASAUtils.pas
===================================================================
--- ZDbcASAUtils.pas	(revision 174)
+++ ZDbcASAUtils.pas	(working copy)
@@ -1108,7 +1110,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := PSingle(sqldata)^;
       DT_DOUBLE      : Result := PDouble(sqldata)^;
       DT_VARCHAR     : begin
@@ -1146,7 +1148,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^ <> 0;
       DT_UNSSMALLINT : Result := PWord(sqldata)^ <> 0;
       DT_INT         : Result := PInteger(sqldata)^ <> 0;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^ <> 0;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^ <> 0;
       DT_FLOAT       : Result := PSingle(sqldata)^ <> 0;
       DT_DOUBLE      : Result := PDouble(sqldata)^ <> 0;
       DT_VARCHAR     : begin
@@ -1184,7 +1186,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := Trunc( PSingle(sqldata)^);
       DT_DOUBLE      : Result := Trunc( PDouble(sqldata)^);
       DT_VARCHAR     : begin
@@ -1257,7 +1259,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := PSingle(sqldata)^;
       DT_DOUBLE      : Result := PDouble(sqldata)^;
       DT_VARCHAR     : begin
@@ -1295,7 +1297,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := PSingle(sqldata)^;
       DT_DOUBLE      : Result := PDouble(sqldata)^;
       DT_VARCHAR     : begin
@@ -1333,7 +1335,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := Trunc( PSingle(sqldata)^);
       DT_DOUBLE      : Result := Trunc( PDouble(sqldata)^);
       DT_VARCHAR     : begin
@@ -1371,7 +1373,7 @@
       DT_SMALLINT    : Result := PSmallint(sqldata)^;
       DT_UNSSMALLINT : Result := PWord(sqldata)^;
       DT_INT         : Result := PInteger(sqldata)^;
-      {$IFNDEF VER130}DT_UNSINT      : Result := PLongWord(sqldata)^;{$ENDIF}
+      DT_UNSINT      : Result := PLongWord(sqldata)^;
       DT_FLOAT       : Result := Trunc( PSingle(sqldata)^);
       DT_DOUBLE      : Result := Trunc( PDouble(sqldata)^);
       DT_VARCHAR     : begin
@@ -1432,7 +1434,7 @@
       DT_SMALLINT    : Result := IntToStr( PSmallint(sqldata)^);
       DT_UNSSMALLINT : Result := IntToStr( PWord(sqldata)^);
       DT_INT         : Result := IntToStr( PInteger(sqldata)^);
-      {$IFNDEF VER130}DT_UNSINT      : Result := IntToStr( PLongWord(sqldata)^);{$ENDIF}
+      DT_UNSINT      : Result := IntToStr( PLongWord(sqldata)^);
       DT_FLOAT       : Result := FloatToStr( PSingle(sqldata)^);
       DT_DOUBLE      : Result := FloatToStr( PDouble(sqldata)^);
       DT_VARCHAR     : SetString( Result, PChar( @PZASASQLSTRING( sqlData).data[0]),

Code: Select all

Index: ZPlainFirebirdInterbaseConstants.pas
===================================================================
--- ZPlainFirebirdInterbaseConstants.pas	(revision 174)
+++ ZPlainFirebirdInterbaseConstants.pas	(working copy)
@@ -41,6 +41,9 @@
 
 {$I ZPlain.inc}
 
+uses
+   ZCompatibility;
+
 const
   IBLocalBufferLength = 512;
   IBBigLocalBufferLength = IBLocalBufferLength * 2;
@@ -503,7 +506,7 @@
 			           { & text types only }
     sqllen:             Short;     { length of data area }
     sqldata:            PChar;     { address of data }
-    sqlind:             {$IFNDEF VER130}PSmallInt{$ELSE}^SmallInt{$ENDIF};  { address of indicator }
+    sqlind:             PSmallInt;  { address of indicator }
                                    { variable }
     sqlname_length:     Short;     { length of sqlname field }
     { name of field, name length + space for NULL }

Code: Select all

Index: ZPlainMysqlConstants.pas
===================================================================
--- ZPlainMysqlConstants.pas	(revision 174)
+++ ZPlainMysqlConstants.pas	(working copy)
@@ -50,6 +50,9 @@
 
 {$I ZPlain.inc}
 
+uses
+   ZCompatibility;
+
 const
 {$IFNDEF MYSQL_STRICT_DLL_LOADING}
   WINDOWS2_DLL_LOCATION = 'libmysql.dll';
@@ -402,13 +405,13 @@
 
   PMYSQL_BIND2 = ^MYSQL_BIND2;
   MYSQL_BIND2 =  record
-    length:            {$IFNDEF VER130}PLongInt{$ELSE}^LongInt{$ENDIF};
-    is_null:           {$IFNDEF VER130}PByte{$ELSE}^Byte{$ENDIF};
+    length:            PLongInt;
+    is_null:           PByte;
     buffer:            PChar;
-    error:             {$IFNDEF VER130}PByte{$ELSE}^Byte{$ENDIF};
+    error:             PByte;
     buffer_type:       TMysqlFieldTypes;
     buffer_length:     LongInt;
-    row_ptr:           {$IFNDEF VER130}PByte{$ELSE}^Byte{$ENDIF};
+    row_ptr:           PByte;
     offset:            LongInt;
     length_value:      LongInt;
     param_number:      Cardinal;
The following patch is only for optimization. Delphi 5 complained about never used variables and that PQFreeMem procedure (this unit uses directly the "mapped" version from ZPlainPostgreeSQL8.pas). Not needed, but optimization is always welcome, I think.

Code: Select all

Index: ZPlainPostgreSqlDriver.pas
===================================================================
--- ZPlainPostgreSqlDriver.pas	(revision 174)
+++ ZPlainPostgreSqlDriver.pas	(working copy)
@@ -395,8 +395,6 @@
 
   {** Implements a driver for PostgreSQL 8.1 }
   TZPostgreSQL8PlainDriver = class(TZAbstractObject, IZPlainDriver,IZPostgreSQLPlainDriver)
-  private
-    procedure PQFreeMem(ptr: Pointer);
   public
     constructor Create;
 
@@ -985,13 +983,11 @@
 end;
 
 function TZPostgreSQL8PlainDriver.DecodeBYTEA(value: string): string;
-var decoded,dest:pchar;
+var decoded:pchar;
     len:Longword;
-    von,nach:string;
 begin
-  decoded:=ZPlainPostgreSql8.PQunescapeBytea(pansichar(value),@len);
+  decoded:=ZPlainPostgreSql8.PQUnescapeBytea(pansichar(value),@len);
   SetLength(result,len);
-  dest:=pchar(result);
   if (len > 0) then Move(decoded^,result[1],len);
   ZPlainPostgreSql8.PQFreemem(decoded);
 end;
@@ -1277,11 +1273,6 @@
   Result := ZPlainPostgreSql8.lo_open(Handle, ObjId, Mode);
 end;
 
-procedure TZPostgreSQL8PlainDriver.PQFreeMem(ptr: Pointer);
-begin
- ZPlainPostgreSql8.PQFreemem(ptr);
-end;
-
 function TZPostgreSQL8PlainDriver.PutBytes(Handle: PZPostgreSQLConnect;
   Buffer: PChar; Length: Integer): Integer;
 begin
Working on D5, D7 and lazarus (0.9.20 Win32).

In case I can post my patch for ZSQLMonitor, please update these to SVN, then I'll make other patches only with ZSQLMonitor stuff.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

This patches have been committed to SVN Testing branch (rev 177). If you can, please check if it works now. (BTW, changed ZStreamBlob as well)

@gto: Concerning your patch forZSQLMonitor : If we commit it now to Testing branch it would give too much collissions when we want to do bugfixes for 6.6.X (we keep it for 6.7 or whatever next version will be called) My advise : copy your workingversion apart ans do an SVN update evere two weeks to keep it up to date. Make your patch the day 6.6.x-stable is released. (Send it as an attach, because I had to do the changes above manualy)

Mark
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

mdaems wrote:This patches have been committed to SVN Testing branch (rev 177). If you can, please check if it works now. (BTW, changed ZStreamBlob as well)

@gto: Concerning your patch forZSQLMonitor : If we commit it now to Testing branch it would give too much collissions when we want to do bugfixes for 6.6.X (we keep it for 6.7 or whatever next version will be called) My advise : copy your workingversion apart ans do an SVN update evere two weeks to keep it up to date. Make your patch the day 6.6.x-stable is released. (Send it as an attach, because I had to do the changes above manualy)

Mark
Right ! :)
Updated here, everithing works. I'll keep my SVN folder always up to date. =)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
brandy
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 27.10.2006, 15:29

Post by brandy »

Hi all,
Thanks for your reply.

Now, I try to work.
Thanks.
Post Reply