Page 1 of 2

Lazarus 0.9.31+MySql server 5.5+windows 7 "Access Viola

Posted: 12.04.2011, 22:07
by ism
Hello, i try to test version from svn://zeos.firmos.at/zeos/branches/testing rev 887
But the program crash when i try to write some sumbols in ztable through DBGrid
And more , the string of any length in DBGrid visible as "??" (russian chars)

this problem repeat in Windows XP and Lazarus 0.9.30 and MySql 5.1

Exception in lines ZAbstractRODataset
ftWideString:
begin
{$IFDEF BDS4_UP}
WStrCopy(Buffer, PWideChar(RowAccessor.GetUnicodeString(ColumnIndex, Result)));
{$ELSE}
line 1381 --------->PWideString(Buffer)^ := RowAccessor.GetUnicodeString(ColumnIndex, Result);
{$ENDIF}
Result := not Result;
end;

Error "Invalid Pointer operation"

test project
http://narod.ru/disk/10018079001/test_proj.7z.html


Version from http://zeosdownloads.firmos.at/downloads/snapshots/
ZEOSLIB_TRUNK_REV834.zip working good

Sorry for bad english

Posted: 13.04.2011, 10:52
by Dali
The same happened to me when testing ADO (yes, I'm aware of the lack of support of the ADO driver under Lazarus):

http://zeos.firmos.at/viewtopic.php?p=12959#12959

So, maybe it's the same problem.

Posted: 13.04.2011, 11:24
by Dali
Anyway, I tried trunk rev 834 and it crashed as well.

Posted: 15.04.2011, 08:46
by Dali
Any clues on this anyone? Please?

Posted: 15.04.2011, 17:58
by ism
It happens, because not allocated memory for the pointer, when function is called

function TZAbstractRODataset.GetFieldData(Field: TField;
Buffer: Pointer): Boolean;

I'm trying to find the problematic place

Posted: 15.04.2011, 18:00
by ism
Who knows where this function is called?

This only happens with DBgrid and Datasource

Posted: 01.05.2011, 12:33
by ism
Details
Сreated a new project (just in case)
Any string row from the database shows as "???"

Image

Posted: 02.05.2011, 07:21
by Zoran
Do not forget to put the line "codepage=UTF8" in Properties property of the ZConnection.

Posted: 02.05.2011, 16:35
by ism
Is not the case, I tried it.

ZConnection1.Connect;
ZSQLProcessor1.Script.Text:='SET NAMES UTF8';
ZSQLProcessor1.Execute;
ZQuery1.Open;

result - access violation

and

codepage=UTF8

result - '??.'

The strung in table is

'привет привет ... '

It must be displayed as '??????? ????????'

Posted: 02.05.2011, 20:38
by ism
I found
Problem in module ZDbcMySqlUtils.pas
function ConvertMySQLTypeToSQLType(TypeName, TypeNameFull, Collation: string): TZSQLType;

Bug appeared in the revision 850, in 848 all ok.


Old procedure return STSTRING
New procedure return STUNICODESTRING

Probably a problem with the processing of type

Posted: 19.05.2011, 20:17
by mdaems
ism,

Did you check the discussion in http://zeos.firmos.at/viewtopic.php?t=2652
That's the thread that caused revision 850.
I'm not working with mysql databases using non latin1 encodings so I'm really unsure how this works/should work exactly.

Mark

Posted: 19.05.2011, 21:41
by mdaems
Found your patch and applied it in SVN rev 903

Posted: 20.05.2011, 13:33
by ism
In Lazarus 0.9.30 by default all strings in UTF8

Enough

Code: Select all

ZConnection1.Connect;
ZSQLProcessor1.Script.Text:='SET NAMES utf8;';
ZSQLProcessor1.Execute;
ZQuery1.Open;



or

Code: Select all

ZConnection1.Properties='CodePage=UTF8'

Posted: 20.05.2011, 13:35
by ism
If something should test, contact me

Posted: 20.05.2011, 14:50
by Dali
I think that it's the same problem in a different database protocol, so I'll say here that Zeos snv 903 is not working for me using PostgreSQL in Lazarus (from today's svn, compiled using fpc 2.4.2).

Database encoding is UTF8. I tried adding "codepage=utf8", even optionally followed by "client_encoding=utf8". In any case, it just crashes down with "invalid pointer operation".

If I do something similar to what you did, editing src/dbc/ZDbcPostgreSQLUtils.pas:

Code: Select all

  if Connection.GetCharactersetCode = csUTF8 then
    case Result of
{$IFNDEF FPC}
      stString: Result := stUnicodeString;
{$ENDIF}
      stAsciiStream: Result := stUnicodeStream;
    end;
... Then it does not crash, but all the special chars reflect as "?".