Josef Kokeš
2012-06-18 06:18:57 UTC
Hi!
Having bought Delphi XE2, I tried to compile my old (well, very old) UDF
in a 64bit mode. I expected a total fail, because the UDF was written in
Delphi 5 for Interbase 6.0, but after I fixed string types, the UDF
actually works with Firebird 2.1 x64. With one exception - a function
which converts VARCHAR to BLOB causes an Access Violation in the server.
I suspect this might have something to do with the fact that x64
pointers are 64 bits long, which causes the blob record to be of
incorrect lenght, but I would like to get a confirmation (possibly even
a solution :-)) from people more experienced with UDF writing that I am.
The SQL declaration:
DECLARE EXTERNAL FUNCTION STRBLOB
CSTRING(32765), BLOB
RETURNS PARAMETER 2
ENTRY_POINT 'STRBLOB' MODULE_NAME 'pwIBUDF';
The function:
function STRBLOB(Value: PAnsiChar; Dest: PBlob): PBlob;
begin
Result := Dest;
Dest^.PutSegment(Dest^.BlobHandle, Value, StrLen(Value))
end;
The blob record (probably wrong for x64):
TISC_BlobGetSegment = function(BlobHandle: PInt;
Buffer: PAnsiChar;
BufferSize: LongInt;
var ResultLength: LongInt): SmallInt; cdecl;
TISC_BlobPutSegment = procedure(BlobHandle: PInt;
Buffer: PAnsiChar;
BufferLength: SmallInt); cdecl;
TBlob = record
GetSegment: TISC_BlobGetSegment;
BlobHandle: PInt;
SegmentCount: LongInt;
MaxSegmentLength: LongInt;
TotalSize: LongInt;
PutSegment: TISC_BlobPutSegment;
end;
PBlob = ^TBlob;
Did anyone try to work with BLOBs in a x64 UDF already?
Thanks,
Josef Kokes
------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)
<*> To change settings via email:
firebird-support-***@yahoogroups.com
firebird-support-***@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
firebird-support-***@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Having bought Delphi XE2, I tried to compile my old (well, very old) UDF
in a 64bit mode. I expected a total fail, because the UDF was written in
Delphi 5 for Interbase 6.0, but after I fixed string types, the UDF
actually works with Firebird 2.1 x64. With one exception - a function
which converts VARCHAR to BLOB causes an Access Violation in the server.
I suspect this might have something to do with the fact that x64
pointers are 64 bits long, which causes the blob record to be of
incorrect lenght, but I would like to get a confirmation (possibly even
a solution :-)) from people more experienced with UDF writing that I am.
The SQL declaration:
DECLARE EXTERNAL FUNCTION STRBLOB
CSTRING(32765), BLOB
RETURNS PARAMETER 2
ENTRY_POINT 'STRBLOB' MODULE_NAME 'pwIBUDF';
The function:
function STRBLOB(Value: PAnsiChar; Dest: PBlob): PBlob;
begin
Result := Dest;
Dest^.PutSegment(Dest^.BlobHandle, Value, StrLen(Value))
end;
The blob record (probably wrong for x64):
TISC_BlobGetSegment = function(BlobHandle: PInt;
Buffer: PAnsiChar;
BufferSize: LongInt;
var ResultLength: LongInt): SmallInt; cdecl;
TISC_BlobPutSegment = procedure(BlobHandle: PInt;
Buffer: PAnsiChar;
BufferLength: SmallInt); cdecl;
TBlob = record
GetSegment: TISC_BlobGetSegment;
BlobHandle: PInt;
SegmentCount: LongInt;
MaxSegmentLength: LongInt;
TotalSize: LongInt;
PutSegment: TISC_BlobPutSegment;
end;
PBlob = ^TBlob;
Did anyone try to work with BLOBs in a x64 UDF already?
Thanks,
Josef Kokes
------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)
<*> To change settings via email:
firebird-support-***@yahoogroups.com
firebird-support-***@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
firebird-support-***@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/