Re: [fpc-pascal] Truncate procedure unable to work under Linux, is this a bug?
On Sun, 17 May 2015, Géza Kovacs Géza wrote: Truncate procedure unable to work under Linux, is this a bug? This code is unable to work under linux: the Truncate drops an error message if the file is larger than 2 or 3 GB. I tested it with Free Pascal 2.6.4 under Debian Jessie 64 bit. It produce the same error message under Ubuntu 12.04 32 bit with Free Pascal 2.4.4 Sometimes I did not get any error message but the file (which was 2 or 3 GB) will be only some hundred MB after truncate... It operates correctly under Windows. It produce the following error message: An unhandled exception occurred at $: EPrivilege : Privileged instruction $ Program File_Trunc; {$MODE OBJFPC} {$H+} uses dos,sysutils; var f : file of byte; fs : int64; begin assign(f,paramstr(1)); ReSet(f); fs := FileSize(f); WriteLn('Original file size: ',fs); fs := fs-3456789; WriteLn('File size after truncate: ',fs); Seek(f,fs); Truncate(f); Close(f); end. Truncate is a leftover from the DOS days. It does not work with files >2 Gb, the file position is 32-bit. There is the Filetruncate function from sysutils: Function FileTruncate (Handle: THandle; Size: Int64) : boolean; but even that does not work with files >2Gb on unix, because the underlying system call does not support it. I don't know what happens on Windows. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] SqlDB + SQLite3 - CreateDB() call
Hi, Does SqlDB+SQLite3 support creating a SQLite database via the TSQLConnection.CreateDB() call? I tested with FPC 2.6.4 and it doesn't seem to work. More specifically, TIBConnection has CreateDB() implemented, but TSQLite3Connection doesn't. Is this implemented in the upcoming FPC 3.0 or in 3.1.1 (trunk)? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SqlDB + SQLite3 - CreateDB() call
On Mon, 18 May 2015, Graeme Geldenhuys wrote: Hi, Does SqlDB+SQLite3 support creating a SQLite database via the TSQLConnection.CreateDB() call? I tested with FPC 2.6.4 and it doesn't seem to work. More specifically, TIBConnection has CreateDB() implemented, but TSQLite3Connection doesn't. Is this implemented in the upcoming FPC 3.0 or in 3.1.1 (trunk)? Open creates the database if it doesn't exist yet. Patches to implement a 'CreateDB' welcome, though. We probably should introduce some extra properties to control the default behaviour. the sql_open call has a variant which has some flags. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] fcl-net and fpasync
Hi All, I try to write a tcp client program, and found this page: http://pascalgeek.blogspot.com/2012/06/encryption-decryption-and-asynchronous.html which is the only resource I found using fcl-net. But there is a big problem: it did not tell how to receive message back from the server. I tried to write something like: EventLoop.Run; while true do begin Stream.WriteAnsiString('Hello'); WriteLn('Server Reply: ' + Stream.ReadAnsiString); Sleep(1000); end; //Active := false; And at the server side, Msg := FClientStream.ReadAnsiString; WriteLn(AddrToString(FClientStream.PeerAddress) + ': ' + Msg); FClientStream.WriteAnsiString('World!'); //added by me It simply generated a runtime error: EReadError : Stream read error As a matter of fact, I also tried to create a thread like this: procedure TMyTCPClient.ConnStateChanged(Sender: TClientConnectionSocket; OldState, NewState: TConnectionState); begin if NewState = connConnected then begin WriteLn('Connected!'); TMsgReceiver.Create(Stream); end; end; constructor TMyTCPClient.TMsgReceiver.Create(AStream: TSocketStream); begin inherited Create(False); FStream := AStream; FreeOnTerminate := True; end; procedure TMyTCPClient.TMsgReceiver.Execute; var s: string; begin while True do begin WriteLn('Now try to receive something...'); s := FStream.ReadAnsiString; WriteLn('Received: ', s); end; end; But it did not receive anything! How can I enable **bi-directional**, asynchronous (event driven) communication using fcl-net, also, is there any document on fpasync?? Thanks a lot! xrfang ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Truncate procedure unable to work under Linux, is this a bug?
Am 2015-05-18 um 09:30 schrieb Michael Van Canneyt: Function FileTruncate (Handle: THandle; Size: Int64) : boolean; but even that does not work with files >2Gb on unix, because the underlying system call does not support it. I don't know what happens on Windows. On windows it should be possible, at least no restriction mentioned in https://msdn.microsoft.com/en-us/library/windows/desktop/aa365531%28v=vs.85%29.aspx ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Boring problem when I try to create a database using SQLdb (again)
On Sat, May 16, 2015 at 2:19 PM, silvioprog wrote: > On Sat, May 16, 2015 at 1:51 PM, Michael Van Canneyt < > mich...@freepascal.org> wrote: >> >> On Sat, 16 May 2015, silvioprog wrote: >> >>> [...] >>> >> Set the stoUseImplicit option on the transaction: >> >> VCon.Transaction.options:=[stoUseImplicit] > > > Thanks for the fast reply buddy. > > I have another problem: my FPC version is 2.6.4, and this option is not > available in this version. =/ > > But just to test, I did it using FPC from trunk, and the following code > returned another error: > > [code] > var > VCon: TPQConnection; > begin > VCon := TPQConnection.Create(nil); > VCon.Transaction := TSQLTransaction.Create(VCon); > try > VCon.Transaction.Options := VCon.Transaction.Options + > [stoUseImplicit]; > VCon.HostName := '127.0.0.1'; > VCon.DatabaseName := 'postgres'; > VCon.UserName := 'postgres'; > VCon.Password := 'postgres'; > VCon.ExecuteDirect( > 'CREATE DATABASE "09_0025" WITH ENCODING=''UTF8'' ' + > ' OWNER="postgres" TEMPLATE="template1" ' + > ' LC_COLLATE=''English_United States.1252'' ' + > ' LC_CTYPE=''English_United States.1252'' '+ > ' CONNECTION LIMIT=-1 TABLESPACE="pg_default"'); > finally > VCon.Free; > end; > end; > [/code] > > Error: > > #0 PQCONNECTION$_$TPQTRANS_$__$$_REGISTERCURSOR$TPQCURSOR at :0 > #1 > PQCONNECTION$_$TPQCONNECTION_$__$$_EXECUTE$TSQLCURSOR$TSQLTRANSACTION$TPARAMS > at :0 > #2 SQLDB$_$TSQLCONNECTION_$__$$_EXECUTEDIRECT$ANSISTRING$TSQLTRANSACTION > at :0 > #3 SQLDB$_$TSQLCONNECTION_$__$$_EXECUTEDIRECT$ANSISTRING at :0 > #4 TFORM1__BUTTON1CLICK(0x1dc248, ) at Unit1.pas:45 > ... > > >> Why methods like "ExecuteDirectPG", "CheckConnectionStatus", >>> "CheckResultError", "TranslateFldType" and "GetExtendedFieldInfo" are not >>> declared as protected methods? >>> >> >> No particular reason. That can be changed. >> >> Michael. > > > Very nice. I can create a patch to move this methods to the protected > area. =) > Done: http://bugs.freepascal.org/view.php?id=28125 -- Silvio Clécio My public projects - github.com/silvioprog ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal