Talk About Network

Google





Data Bases > IBM DB2 > Re: UDF ****tab...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 12 Topic 9074 of 9564
Post > Topic >>

Re: UDF ****tability?

by Knut Stolze <stolze@[EMAIL PROTECTED] > Jul 16, 2008 at 07:32 PM

esmith2112 wrote:

> void SQL_API_FN hash(SQLUDF_VARCHAR *str,
>                       SQLUDF_VARCHAR     *outHash,
>                       SQLUDF_SMALLINT    *strNullInd,
>                       SQLUDF_SMALLINT    *outHashNullInd,
>                       SQLUDF_TRAIL_ARGS)

Could you show us the exact CREATE FUNCTION statement that you used?

> {
>    int i;
>    unsigned char hash_str[40];
> 
>    if (*strNullInd == -1)
>    {
>      *outHashNullInd = -1;
>    }
>    else
>    {
>      i = strlen(str);
>      my_hash((unsigned char *) str, i, hash_str);

Could you show us my_hash as well?  Maybe you run into a buffer overflow
there since you don't pass along the size of the "hash_str" buffer.

Also, does "my_hash" return some sort of error information?  If so, you
may want to check that.

>      sprintf(outHash, "%X", hash_str);

The %X is not be right here. %X expects an "unsigned int", but you provide
a char *.  For example, my compiler complains about this:

$ g++ -Wall -Wextra a.cpp
a.cpp: In function ‘int main()’:
a.cpp:7: warning: format ‘%X’ expects type ‘unsigned int’, but
argument 2 has type ‘char*’

>      *outHashNullInd = 0;
>    }
> }

-- 
Knut Stolze
Data Warehousing for DB2 z/OS
IBM Germane Research & Development
 




 12 Posts in Topic:
UDF Portability?
esmith2112 <esmith2112  2008-07-10 05:20:49 
Re: UDF Portability?
Serge Rielau <srielau@  2008-07-10 09:19:39 
Re: UDF Portability?
Udo <udo.weigl@[EMAIL   2008-07-10 07:06:22 
Re: UDF Portability?
esmith2112 <esmith2112  2008-07-10 07:28:43 
Re: UDF Portability?
esmith2112 <esmith2112  2008-07-10 08:31:26 
Re: UDF Portability?
Serge Rielau <srielau@  2008-07-10 13:16:14 
Re: UDF Portability?
"Dave Hughes" &  2008-07-12 15:57:39 
Re: UDF Portability?
Knut Stolze <stolze@[E  2008-07-11 12:41:54 
Re: UDF Portability?
esmith2112 <esmith2112  2008-07-11 05:34:23 
Re: UDF Portability?
Knut Stolze <stolze@[E  2008-07-16 19:32:28 
Re: UDF Portability?
esmith2112 <esmith2112  2008-07-14 13:30:02 
Re: UDF Portability?
esmith2112 <esmith2112  2008-07-15 13:45:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 22:07:22 PST 2009.