Board index » delphi » Building UDF Lib for IB601 with Kylix + IBX65

Building UDF Lib for IB601 with Kylix + IBX65

Hi,

sorry that I post my Kylix question here, but there is no IBX-Kylix
newsgroup :(.

I Have Problems when building UDF in Kylix 2 Ent. + IBX65, dealing with
dates.
They all return "NULL" Values and my IBConsole crashes ...

I tried to use "isc_decode_date" / "isc_decode_sql_date" as it was described
in many howto.

Has anybody got a piece of code for me that _works_?

My code just works find, when dealing with integers or doubles ... but
crashes when using dates.

Thanks ...

Robert Hilbrich

 

Re:Building UDF Lib for IB601 with Kylix + IBX65


In article <a5g7ii$1rg$0...@news.t-online.com>, hilbr...@cpc4u.de
says...

Quote

> Has anybody got a piece of code for me that _works_?

        Look at this:

http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=17065

        Should work well in both Delphi and Kylix.

        HTH,

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Quote
> http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=17065

> Should work well in both Delphi and Kylix.

Thank you for the hint ... I tried it with the following results:

Our Linux (SuSE 7.2) Interbase Server with Kylix 2 Ent. trial + IBX (from
extreme toys ...) compiles the source well. But when using the routine
"isc_decode_sql_date /isc_decode_timestamp" it crashed our server.
Error: -902 cannot read from connection.

When I comment the line "isc_..." out everything is normal - no crash - it
works.

My next try was to use a windows ibase server (same edition as above) on
win2k. I coded the same dll/so in Delphi 6 Enterprise - declared the
function - and it worked ... it worked with the time routine!!

I would like to use the server on __Linux__ and compile the UDFs in Kylix.
What did I do wrong??? I even tried to start IBase as root under linux - but
no difference.

I would appreciate any help you can give me ...

Robert Hilbrich

Re:Building UDF Lib for IB601 with Kylix + IBX65


In article <a5i9r4$2u6$0...@news.t-online.com>, hilbr...@cpc4u.de
says...

Quote

> Our Linux (SuSE 7.2) Interbase Server with Kylix 2 Ent. trial + IBX (from
> extreme toys ...) compiles the source well. But when using the routine
> "isc_decode_sql_date /isc_decode_timestamp" it crashed our server.
> Error: -902 cannot read from connection.

        My guess is that the SO is somehow not being loaded.  In Delphi,
the CheckIBLoaded call in the initialization section does this.  Calling
a nil function will AV and crash the IB server.

Quote
> When I comment the line "isc_..." out everything is normal - no crash - it
> works.

        Here's an experiment:  Change your UDF to return a different value
depending upon whether the function isc_decode_sql_date is Assigned.  
(Don't call the function, just check to see if it's assigned.)

        I don't have a Linux box right now or I'd try it myself.  

        HTH,

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Quote
> I don't have a Linux box right now or I'd try it myself.

It's time ... :)

Re:Building UDF Lib for IB601 with Kylix + IBX65


Quote
> Here's an experiment:  Change your UDF to return a different value
> depending upon whether the function isc_decode_sql_date is Assigned.
> (Don't call the function, just check to see if it's assigned.)

How do I check, whether the function isc_... is assigned?? My UDF looks like
...
(if I remember right ...)

function fn_test (var ib_date : TISC_date) : Integer; cdecl;
var tm_date : TM;
begin
    //isc_decode_sql_date(@tm_date, @ib_date);
    Result:=5;
end;

I know this seems to be nonsense. But it crashes, when I remove the
comment-signs.

Best Regards ...

Robert

Re:Building UDF Lib for IB601 with Kylix + IBX65


In article <a5iu2b$kkt$0...@news.t-online.com>, hilbr...@cpc4u.de
says...

Quote

> How do I check, whether the function isc_... is assigned?? My UDF looks like
> ...
> (if I remember right ...)

> function fn_test (var ib_date : TISC_date) : Integer; cdecl;
> var tm_date : TM;
> begin

    if Assigned(isc_decode_sql_date) then begin
      Result := 1;
    end else begin
      Result := 0;

Quote
> end;

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Ok,
I started new from the beginning:
1) I downloaded RPM version of Interbase 6.0.1. from
borland-open-source-site --> rpm -i ... OK
2) I downloaded Kylix Trial V.2 Build 6.42 from borland --> installing ...
OK
3) I downloaded IBX 6.01 from borland / kylix - Page --> installing dclip...
OK
4) I coded the following project in Kylix:

//DPR-file
library SGM;

uses
  SysUtils,
  Classes,
  vertrag in 'vertrag.pas';

begin
end.

//vertrag.pas
unit vertrag;

interface

uses IBExternals, IBHeader, IBIntf;

function Fn_Test (var ib_date: ISC_DATE) : Integer; cdecl;
function Fn_Test2(var ib_date: ISC_DATE) : Integer; cdecl;

exports Fn_Test, Fn_Test2;

implementation

function Fn_Test (var ib_date: ISC_DATE) : Integer;
var tm_date: TM;
begin
        If Assigned(isc_decode_sql_date) Then Result := 1
        Else                                  Result := 0;
end;

function Fn_Test2 (var ib_date: ISC_DATE) : Integer;
var tm_date: TM;
begin
        isc_decode_sql_date(@ib_date, @tm_date);
        result := tm_date.tm_year + 1900;
end;

initialization
        IsMultiThread := True;
        CheckIBLoaded;
end.

//

5) I compiled it ... OK, copied libSGM.so to /opt/interbase/UDF
6) I started interbase (ibmgr -start -forever)
7) I declared the external functions

DECLARE EXTERNAL FUNCTION FN_TEST
DATE
RETURNS INTEGER BY VALUE
ENTRY_POINT 'Fn_Test' MODULE_NAME 'libSGM.so';

DECLARE EXTERNAL FUNCTION FN_TEST2
DATE
RETURNS INTEGER BY VALUE
ENTRY_POINT 'Fn_Test2' MODULE_NAME 'libSGM.so';

COMMIT;

8) I stopped IBase (ibmgr -shut -p masterkey) and restarted the server
process (ibmgr -start -forever) ... OK
9) I start isql an executed the following queries:

SELECT FN_TEST(CURRENT_DATE) from rdb$database;
===> 1
SELECT FN_TEST2(CURRENT_DATE) from rdb$database;
==> Error: Statement failed SQL Code -902
==> Cannot read from connection ...

So well, I hope I can help with it, to find the error in IBX/IB.

Thanks for your help ...

Robert Hilbrich

Re:Building UDF Lib for IB601 with Kylix + IBX65


        OK, I'm really starting to scratch my head here.  Try grabbing
FreeUDFC from:

http://www.cvalde.com/misc/packages_and_utilities.htm

        ...and building it with GCC.  Do those routines work for you?

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Quote

> OK, I'm really starting to scratch my head here.

Im so sorry ... (but thank you)

Quote
> Try grabbing
> FreeUDFC from:

> http://www.cvalde.com/misc/packages_and_utilities.htm

Ok, i'll try ...

Robert

Re:Building UDF Lib for IB601 with Kylix + IBX65


I tried and failed ...

Downloading ... OK
Compiling  ... warnings:
"date_functions.o:  cdow_long undefined reference to 'ib_util_malloc'
                    cdow_short undefined reference to 'ib_util_malloc'
                    cmonth_long undefined reference to 'ib_util_malloc'
                    cdow_short undefined reference to 'ib_util_malloc'
                    max_date undefined reference to 'ib_util_malloc'
more undefined references to 'ib_util_malloc' follow ...

But it Build the FreeLibC-File;

Declaring external functions  (isql /sgm_db/sgm.gdb -i ib_declarations.sql)
... OK
Testing function LTrim and others ... SERVER CRASH

So well ... doesn't seem to work though. As I said, I installed Borland's
RPM version of IB6.0.1.0. Could this matter.

Robert

Re:Building UDF Lib for IB601 with Kylix + IBX65


In article <a5lkfa$8ji$0...@news.t-online.com>, hilbr...@cpc4u.de
says...

Quote
> I tried and failed ...

> Downloading ... OK
> Compiling  ... warnings:
> "date_functions.o:  cdow_long undefined reference to 'ib_util_malloc'
>                     cdow_short undefined reference to 'ib_util_malloc'
>                     cmonth_long undefined reference to 'ib_util_malloc'
>                     cdow_short undefined reference to 'ib_util_malloc'
>                     max_date undefined reference to 'ib_util_malloc'
> more undefined references to 'ib_util_malloc' follow ...

        ib_util_malloc shouldn't be needed for the date routines at all.  
It's only needed when allocating memory to be used in conjunction with
FREE_IT UDF declarations, which the date functions don't have.  
Generally, this technique is used only for strings/Blobs.

        My suggestion would be to pull out just one of these routines into
a c file by itself and get rid of any references to ib_util_malloc.  You
shouldn't need it.

Quote
> But it Build the FreeLibC-File;

> Declaring external functions  (isql /sgm_db/sgm.gdb -i ib_declarations.sql)
> ... OK
> Testing function LTrim and others ... SERVER CRASH

        Probably because it wants ib_util_malloc.

Quote

> So well ... doesn't seem to work though. As I said, I installed Borland's
> RPM version of IB6.0.1.0. Could this matter.

        I very much doubt it, although I would advise going to at least
6.0.1.6 for other reasons when possible.

        HTH,

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Hi,
now we tried to build some date-routines on our own - and it worked.
We built a YEAR() routine which accepts a date-parameter and returns the
year as int by value.
IT REALLY WORKED ...

So what the hell (sorry) is it in IBX that makes our server stuck???
How can I help u find the bug?

Quote
> Probably because it wants ib_util_malloc.

> > So well ... doesn't seem to work though. As I said, I installed
Borland's
> > RPM version of IB6.0.1.0. Could this matter.

> I very much doubt it, although I would advise going to at least
> 6.0.1.6 for other reasons when possible.

I deinstalled IB601 (rpm -e InterBaseSS...)... OK
Then I downloaded IB 602 from mers (site is very slow, isn't it?) and
installed the tar-file to /opt. ... OK
Now working with the win32 console is fine, but using the local isql gives
me the error message:
"inconsistent table lock version number; 114 expected 14" (if i remember
right...)

I tried to search at mers but the site is down or overstressed.
What can I do??

Robert

Re:Building UDF Lib for IB601 with Kylix + IBX65


In article <a609tb$8d0$0...@news.t-online.com>, hilbr...@cpc4u.de
says...

Quote
> now we tried to build some date-routines on our own - and it worked.
> We built a YEAR() routine which accepts a date-parameter and returns the
> year as int by value.
> IT REALLY WORKED ...

> So what the hell (sorry) is it in IBX that makes our server stuck???

        Do you think it's IBX or the IB API?  They aren't the same thing.

Quote
> How can I help u find the bug?

        Try using the IB API without using IB to load the SO.

Quote
> I deinstalled IB601 (rpm -e InterBaseSS...)... OK

        BTW, 601 is old.  You can get 6.0.1.6 or 6.0.2.0 from
http://mers.com

Quote
> Then I downloaded IB 602 from mers (site is very slow, isn't it?) and
> installed the tar-file to /opt. ... OK
> Now working with the win32 console is fine, but using the local isql gives
> me the error message:
> "inconsistent table lock version number; 114 expected 14" (if i remember
> right...)

> I tried to search at mers but the site is down or overstressed.
> What can I do??

        http://www.google.com yields:

http://community.borland.com/article/0,1410,25429,00.html

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
     Delphi/InterBase WebLog: http://delphi.weblogs.com
     InterBase PLANalyzer (Free IB optimization tool):
          http://delphi.weblogs.com/IBPLANalyzer

Re:Building UDF Lib for IB601 with Kylix + IBX65


Quote
> Do you think it's IBX or the IB API? They aren't the same thing.

I think, it's ibx - when I coded the test-function in c,i only used the
api-function (isc_decode_date). IBX, I think is a layer above the IB Api
using the api routines such as isc_decode_date. So when I directly call
routines from the api in an UDF written in c without any help of ibx and
everything is fine ... then I think IBX is "guilty".

Quote

> > How can I help u find the bug?

> Try using the IB API without using IB to load the SO.

?? What do you mean? Write a programm (not a udf) dealing with the api??

Quote
> > Then I downloaded IB 602 from mers (site is very slow, isn't it?) and
> > installed the tar-file to /opt. ... OK
> > Now working with the win32 console is fine, but using the local isql
gives
> > me the error message:
> > "inconsistent table lock version number; 114 expected 14" (if i remember
> > right...)

> > I tried to search at mers but the site is down or overstressed.
> > What can I do??

> http://www.google.com yields:

> http://community.borland.com/article/0,1410,25429,00.html

I found this article as well.
But:
1) The footer says it applies to IB56 and lower ...
2) there is no program gds_drop that i could call in my bin directory ...
3) rebooting didn't help as well ...

I think it's out of date ...

Thanks for your time ...

Robert

PS: Thought about your linux-box?? ;)

Go to page: [1] [2]

Other Threads