On 6-6-2010 11:54, Michael Van Canneyt wrote: > On Sun, 6 Jun 2010, Jim wrote: >> On 5-6-2010 12:23, Michael Van Canneyt wrote: >>> On Sat, 5 Jun 2010, Jim wrote: >>>> On 5-6-2010 10:47, Michael Van Canneyt wrote: >>>>> On Sat, 5 Jun 2010, Jim wrote: >>>> <snip> > > Is the firebird UDF written in fpc ?
Yep, but the error still happens even if I strip out the UDF - which I've done now. Here's the source code for the debug UDF anyway - without some comments: {$IFDEF FPC} // Compiler constants for the FreePascal compiler. {$MODE OBJFPC}// Needed for the Result := construct {$SMARTLINK ON}// Try to slim down resulting binary. Seems to work only on Windows at the moment. Apparently doesn't work on dlls {$PACKRECORDS C} // Try packrecords c to pack bytes just the way c does it. Doesn't seem to have any effect, but let's leave it in. {$IFDEF WINDOWS} {$VERSION 1.0} // DLL version number {$ENDIF} {$ENDIF} library fbdebug; {$IFDEF FPC} uses Classes, SysUtils; {$ENDIF} function ib_util_malloc(Bytes: integer): pointer; cdecl; external 'ib_util'; function debug(Message, DestinationFile: PChar): longint; cdecl; export; // Appends Message to File. Returns 0 if succesful. // 73 if file system error (todo: lookup FreeBSD EX_CANTCREAT sysexits exit code) // longint=4 bytes, signed. We don't use unsigned, because // Firebird can't handle that at the moment. var OutputFile: TFileStream; RightNow: String; const LineFeed = #13#10; begin RightNow:=DateTimeToStr(Now)+':'; Result := 73; //Default failure code if DestinationFile <> '' then begin if FileExists(DestinationFile) then begin OutputFile := TFileStream.Create(DestinationFile, fmOpenReadWrite or fmShareDenyWrite); OutputFile.Seek(0, soFromEnd); end else begin OutputFile := TFileStream.Create(DestinationFile, fmCreate or fmOpenWrite or fmShareDenyWrite); end; try OutputFile.Write(RightNow[1], Length(RightNow)); OutputFile.Write(Message^, Length(Message)); OutputFile.Write(LineFeed[1], Length(Linefeed)); Result := 0; finally OutputFile.Free; end; //try end //if outputfile else //No outputfile given begin Result := 65; //equivalent to EX_DATAERR in FreeBSD end; {$IFDEF DEBUG} writeln('debug: message: ', Message, ' to file: ', OutputFile); writeln('Result code: ', Result); {$ENDIF} end; exports debug Name 'debug'; begin end. > Well, I've succesfully used embedded firebird with FPC, so that part > should work. But I didn't use exceptions in Firebird, and also no UDF, so > these are 2 unknowns for me. Well, as long as you're there and willing to help ;) - for embedded I have to copy over the dlls etc. Tried it for win 64; was able to connect to the database using isql.exe so assume I've got the proper dlls set. Next, my db access unit uses these database units: sqldb {queries, db access} ibconnection {Firebird access}; and in the implementation section it uses: ibase60dyn {for embedded firebird declaration} DB {for parameter types}; In my db setup code, I tried to do this: FUseEmbedded := true; UseEmbeddedFirebird := FUseEmbedded; //know this option is deprecated, but can't get embedded to work FDBHost := ''; //empty for embedded; FDBPort := 3050; //Default port for Firebird is 3050; maybe 0 for embedded? FDBDatabase := 'flocate'; //for embedded, specify database filename //for normal db: 'flocate'; //use an alias on firebird server for easy management FDBUser := 'SYSDBA'; FDBPassword := 'masterkey'; if false = false then begin DBParams := TStringList.Create; DBParams.Add('port=' + IntToStr(FDBPort)); end; If I set the port to either 3050 or 0, I get an error: EControlC/Control-C hit If I don't add the port to the DBParams when using embedded: if FUseEmbedded = false then I get an access violation. I'm using the 64 bit Firebird client version 2.1.2.18118 (also tried with a 2.5 release candidate) What am I doing wrong? > > Maybe there is some special handling required for firebird exceptions, > although that would surprise me. Normally I'd simply expect this to > be a special error code, and the message of the exception as the error > message... True, I have some docs regarding Delphi and Firebird exception handling somewhere, I'll look them up... _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal