#1 Re: mORMot 1 » TODBCLib report "Unspecified error" when record is empty » 2012-12-12 01:59:34

OK.

Its my pleasure if can help synopse.

I just tested CRUD on postgresql, all is work.

#2 mORMot 1 » TODBCLib report "Unspecified error" when record is empty » 2012-12-11 09:17:14

moggco
Replies: 2

I use the odbc classes to operate Postgresql database, my code as follow:

      Prop := TODBCConnectionProperties.Create('pgds','traffic','user','pass');
      Connection := TODBCConnection.Create(Prop);
      Connection.Connect;
      Connection.StartTransaction;
      Tbl := TODBCStatement.Create(Connection);
      Tbl.Execute(RawUTF8('delete from nodes'), false);
      TiberoConnection.Commit;

if record is empty, it raise "Unspecified error", the value of Status is 100 that meaning no data processed.

The raise error puzzling me for hours, I finally found the answer after check my codes and odbc configure again and again.

#3 Re: mORMot 1 » Synopse SQlite3 Unit Tests » 2011-06-08 14:44:28

Changed the code

WinAnsiToUtf8('LastName=''M'#244'net'' ORDER BY LastName');

to

      s := WinAnsiToUtf8('LastName=''M'+chr(244)+'net'' ORDER BY LastName');

Yes, change all such char in "WinAnsiToUtf8(...)" from #nnn to chr(nnn).
Then all tests passed.

#4 Re: mORMot 1 » TSQLRestClientURINamedPipe can't connect to server "Test" » 2010-12-19 04:23:44

In XE, those definitions are same as yours.

ab wrote:

This (could) mean(s) that InitializeSecurity() fails to create a valid TSecurityAttributes content.

But there is no reason why it changed with XE...

Could you check out the WIndows.pas unit in XE, to see if those definitions match:

function InitializeSecurityDescriptor(pSecurityDescriptor: PSecurityDescriptor;
  dwRevision: DWORD): BOOL; stdcall;
function SetSecurityDescriptorDacl(pSecurityDescriptor: PSecurityDescriptor;
  bDaclPresent: BOOL; pDacl: PACL; bDaclDefaulted: BOOL): BOOL; stdcall;

type
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: BOOL;
  end;

const
  SECURITY_DESCRIPTOR_REVISION = 1;
  SECURITY_DESCRIPTOR_REVISION1 = 1;
  SECURITY_DESCRIPTOR_MIN_LENGTH = 20;

I try the trunk version, but the createnamepipe is failed.

    aPipe := CreateNamedPipe(Pointer(fPipeName),
      PIPE_ACCESS_DUPLEX,
      PIPE_TYPE_BYTE or PIPE_READMODE_BYTE or PIPE_WAIT,
      PIPE_UNLIMITED_INSTANCES, 0, 0, 0, @fPipeSecurityAttributes);
    if aPipe=INVALID_HANDLE_VALUE then

aPipe==INVALID_HANDLE_VALUE

I review the code, I can't find any wrong code.
TSecurityAttributes  should not use packed record,  in XE's windows.pas

  PSecurityAttributes = ^TSecurityAttributes;
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: BOOL;
  end;

in Jediwinapi,

  PSECURITY_ATTRIBUTES = ^SECURITY_ATTRIBUTES;
  {$EXTERNALSYM PSECURITY_ATTRIBUTES}
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: LPVOID;
    bInheritHandle: BOOL;
  end;

of course, for TSecurityAttributes  , the packed record is same as record.

#5 Re: mORMot 1 » TSQLRestClientURINamedPipe can't connect to server "Test" » 2010-12-18 11:06:17

Open SQLite3Commons.pas, in "procedure TSQLRestServerNamedPipe.Execute",  change code as follow:

    aPipe := CreateNamedPipe(pointer(fPipeName),
      PIPE_ACCESS_DUPLEX,
      PIPE_TYPE_BYTE or PIPE_READMODE_BYTE or PIPE_WAIT,
      PIPE_UNLIMITED_INSTANCES, 0, 0, 0, nil{@fPipeSecurityAttributes});

In my XE, its work.

Refer to http://msdn.microsoft.com/en-us/library … S.85).aspx

#6 Re: mORMot 1 » About the file format » 2010-12-09 03:53:13

ab wrote:

Which version of Delphi are you using?

String constant must be perhaps forced as WinAnsiString. Does WinAnsiString('....'#233#224'...') work? Or perhaps const aTest1: WinAnsiString = '....'#233#224'...'; ?

Delphi XE.

Use

const
    aTest1: WinAnsiString = ''', ''Morse'', ''a'#233#234#231''', 1791, 1872);';

the result same as above.

Maybe there are two solutions:
1. save all source files encode as utf8  but not 7 bit ASCII code.
2. use wide char for Delphi 2009~2011, that is #233 replace with #$00E9

#7 Re: mORMot 1 » About the file format » 2010-12-07 08:15:47

ab wrote:

I've uploaded a version in pure 7 bit ASCII code.

All WinAnsi characters are encoded as #232 const or such.

All source files should now load with no encoding problem.

That not a good solution in my machine.
Yes, that Delphi IDE load the source is no encoding problem, but as a widestring, its too bad.
Such as

s1: string;

s1 := ''', ''Morse'', ''a'#233#224#231''', 1791, 1872);'

You code page is 1252, but my locale is 2052 and code page is 936, so delphi treat #233#224 as a widechar, and #231 as $003F that is '?',  its illegal character in MBCS of my windows .  The test can't passed.

The damn code conversion. I don't know how to deal with it.

#8 mORMot 1 » About the file format » 2010-11-29 13:23:00

moggco
Replies: 6

All file is winAnsi. When Delphi XE open some file , such as SynSelfTests.pas, XE cannot display correctly, and many test is fail for illegible characters.
So I must open the source file with VIM, copy&paste to XE, then save as utf8. After fixed some hash code and added some encode of string, all tests is pass.

sample:

procedure TTestSQLite3Engine.DirectAccess;
procedure InsertData(n: integer);
var i: integer;
    s, ins: RawUTF8;
    R: TSQLRequest;
begin
  // this code is a lot faster than sqlite3 itself, even if it use Utf8 encoding:
  // -> we test the engine speed, not the test routines speed :)
 ins := 'INSERT INTO People (FirstName,LastName,Data,YearOfBirth,YearOfDeath) VALUES (''';
 for i := 1 to n do begin
   str(i,s);
   // we put some accents in order to test UTF-8 encoding
   R.Prepare(Demo.DB,ins+'Salvador'+s+''', ''Dali'', ?, 1904, 1989);');
   R.Bind(1,PAnsiChar(WinAnsiToUtf8('aéà?')),length(WinAnsiToUtf8('aéà?')){4}); // Bind Blob
procedure TTestSQLite3Engine._TSQLRestClientDB;
...

Check(Data=WinAnsiToUtf8('aéàç'));

......

Check((DataS.Size=7{4}) and (PCardinal(DataS.Memory)^=$C3A9C361{E7E0E961}));

My question is how to deal with such thing simpler and safer ?

#9 mORMot 1 » Is there a typo about TTestSynopsePDF._TPdfDocument? » 2010-11-29 12:43:59

moggco
Replies: 1

In the SynSelfTests.pas:

Procedure TTestSynopsePDF._TPdfDocument;
var MS: THeapMemoryStream;
    i,y: integer;
    embed: boolean;
const
  Hash: array[boolean] of Cardinal =
    ($7DFB537,$4CC9F0E8);
  Name: array[boolean] of PDFString =
    ('Arial','Helvetica');
begin
  MS := THeapMemoryStream.Create;
  with TPdfDocument.Create do
  try
    for embed := false to true do begin
      Info.CreationDate := Date;
      StandardFontsReplace := embed;
      AddPage;
      Canvas.SetFont('arial',10,[]);
      Check(Canvas.Page.Font.Name=Name[embed]);
      y := 800;
      for i := 1 to 30 do begin
        Canvas.SetFont('Arial',9+i,[]);
        Canvas.TextOut(100,y,WinAnsiString('Texte accentu?n?+IntToStr(i)));
        dec(y,9+i);
      end;
      SaveToStream(MS,Date);
      Check(Hash32(MS.Memory,MS.Position)=Hash[embed]);
      if not embed then begin
        NewDoc;
        MS.Clear;
      end;
    end;
// MS.SaveToFile(ChangeFileExt(paramstr(0),'.pdf'));
  finally
    Free;
    MS.Free;
  end;
end;

I modified as follow:

procedure TTestSynopsePDF._TPdfDocument;
var MS: THeapMemoryStream;
    i,y: integer;
    embed: boolean;
const
  Hash: array[boolean] of Cardinal =
    ($A9373411,$61C142{.$7DFB537,$4CC9F0E8});
  Name: array[boolean] of PDFString =
    ('Arial','Tahoma');
begin
  MS := THeapMemoryStream.Create;
  with TPdfDocument.Create do
  try
    for embed := false to true do begin
      Info.CreationDate := Date;
      StandardFontsReplace := embed;
      AddPage;
      Canvas.SetFont(Name[embed],10,[]);
      writeln(Canvas.Page.Font.Name);
      Check(Canvas.Page.Font.Name=Name[embed]);
      ...

Canvas.SetFont(Name[embed],10,[]);

ps. In my Windows, there is not exist 'Helvetica' font, so I use 'Tahoma' font.

Board footer

Powered by FluxBB