[patch_done] Fix datetime to string Lazarus program MySql

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
ism
Zeos Test Team
Zeos Test Team
Posts: 202
Joined: 02.10.2010, 20:48

[patch_done] Fix datetime to string Lazarus program MySql

Post by ism »

Need to replace all stUnicodeString to stString for Lazarus in other modules for fix Lazarus crashes

It seems a problem in Lazarus and not in zeos.

Discussion
http://zeos.firmos.at/viewtopic.php?t=3179

Code: Select all

Index: src/dbc/ZDbcMySqlUtils.pas
===================================================================
--- src/dbc/ZDbcMySqlUtils.pas	(revision 903)
+++ src/dbc/ZDbcMySqlUtils.pas	(working copy)
@@ -243,14 +243,22 @@
           (PMYSQL_FIELD(FieldHandle)^.charsetnr = 83) or
         	((PMYSQL_FIELD(FieldHandle)^.charsetnr>=192) and
           (PMYSQL_FIELD(FieldHandle)^.charsetnr<=210)) )(*  the end is not fix ??? *) then
-        Result := stUnicodeString
+    {$IFDEF FPC}
+      Result := stString
+    {$ELSE}
+      Result := stUnicodeString
+    {$ENDIF}
       else
       if ( // UCS2
         	(PMYSQL_FIELD(FieldHandle)^.charsetnr = 35) or
           (PMYSQL_FIELD(FieldHandle)^.charsetnr = 90) or
         	((PMYSQL_FIELD(FieldHandle)^.charsetnr>=128) and
           (PMYSQL_FIELD(FieldHandle)^.charsetnr<=146)) )(*  the end is not fix ??? *) then
-        Result := stUnicodeString
+    {$IFDEF FPC}
+      Result := stString
+    {$ELSE}
+      Result := stUnicodeString
+    {$ENDIF}
       else
         Result := stString;
     FIELD_TYPE_ENUM:
Last edited by ism on 21.05.2011, 20:20, edited 1 time in total.
ism
Zeos Test Team
Zeos Test Team
Posts: 202
Joined: 02.10.2010, 20:48

Post by ism »

In Delphi XE (2011) all ok and does not require changes

Delphi correctly working with stUnicodeString
bobo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 20.05.2011, 03:19

Post by bobo »

Yes, this seems to fix it. Thank you.

I am not sure we can call this a "problem" with Lazarus. It is just that FPC and Lazarus uses UTF-8 strings by default on all operating systems.
bobo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 20.05.2011, 03:19

Post by bobo »

There might be other places when something like this needs to be done for FPC/Lazarus.
The other day I again saw a lot of ?? field value returns for some simple string fields (not calculated fields, just normal db fields) on Windows (did not check on Linux).
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Done. SVN rev 928. Testing branch.
Image
Post Reply