ER checksum routines - CLOB support?
Posted in 2006
Topics: Data Types & Schema Design, Platform-Specific Issues, Versions, Editions & End-of-Life
Solaris 9
IDS 10.00 FC4
Compiling, linking and registrating ER checksum routines done without a
problem (on both primary and target)
But, when using "cdr check" on a table with CLOB field error pops up .
Looking at checksum routines definitions I can see two of them for handling
byte/text types, but no blob/clob.
So, if you do something like
select checksum(<CLOB_field_here>, NULL) from table_with_clob_field
you'll get
674: Routine (checksum) can not be resolved.
Select checksum on other (non-clob) fields of the same table runs fine.
Also, if you first "cast" clob field to lvarchar
select checksum(cloboutput(<CLOB_field_here>), NULL) from
table_with_clob_field
it runs fine.
This doesn't seem like bug, more like a feature request.
Before I contact Tech Support I wanted to hear your opinions.
Madison?
Anyone?
Thanks.
Davorin Kremenjas wrote:
> Solaris 9
> IDS 10.00 FC4
>
> Compiling, linking and registrating ER checksum routines done without a
> problem (on both primary and target)
> But, when using "cdr check" on a table with CLOB field error pops up .
> Looking at checksum routines definitions I can see two of them for handling
> byte/text types, but no blob/clob.
We didn't have ways to implement the UDR on all data types, but I
thought that we had implemented the checksums for blobs and clobs, but
not byte and text columns.
That said - to do the checksum for blobs and bytes, you would need to
do something like the following.
-------------------------------------------------------------------
#define KILLO 1028
#define BSIZE_IN_K 32
#define Forever while (1)
#define Once while (0)
mi_integer
sblob_checksum(MI_LO_HANDLE *loptr, mi_integer checksumParm, MI_FPARAM *fp)
{
mi_unsigned_integer crc = (mi_fp_argisnull(fp, 1) == MI_TRUE) ?
0 : (mi_unsigned_integer)checksumParm;
MI_CONNECTION *conn;
MI_LO_SPEC *lo_spec = NULL;
MI_LO_FD lo_fd;
MI_LO_STAT *lo_stat = NULL;
mi_integer result;
char *buff = NULL;
mi_integer buffsize = BSIZE_IN_K*KILLO;
mi_integer Ksize;
if (mi_fp_argisnull(fp, 0) == MI_TRUE)
return checksumParm;
do {
if ((conn = mi_open(NULL, NULL, NULL)) == NULL)
break;
if ((buff = (char*)mi_alloc(buffsize)) == NULL)
break;
if ((lo_fd =
mi_lo_open(conn, loptr, MI_LO_RDONLY)) == MI_ERROR)
break;
do
{
if ((result =
mi_lo_read(conn, lo_fd, buff, buffsize)) == MI_ERROR)
break;
if (result == 0)
break;
crc = accum_crc(buff, result, crc);
if (result < buffsize)
break;
} Forever;
mi_lo_close(conn,lo_fd);
} Once;
if (buff)
mi_free(buff);
return (mi_integer)crc;
}
---------------------------------------------------------
and the sql portion should be something like...
---------------------------------------------------------
create function checksum(p1 blob, p2 integer)
RETURNS integer
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE)
EXTERNAL NAME "$INFORMIXDIR/udrs/checksum.so(sblob_checksum)"
LANGUAGE C;
create function checksum(p1 clob, p2 integer)
RETURNS integer
with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE)
EXTERNAL NAME "$INFORMIXDIR/udrs/checksum.so(sblob_checksum)"
LANGUAGE C;
-----------------------------------------------------------
Blobs and clobs can use the same checksum routine because internally
they are pretty much the same thing.
> So, if you do something like
>
> select checksum(<CLOB_field_here>, NULL) from table_with_clob_field
>
> you'll get
>
> 674: Routine (checksum) can not be resolved.>
> Select checksum on other (non-clob) fields of the same table runs fine.
> Also, if you first "cast" clob field to lvarchar
>
> select checksum(cloboutput(<CLOB_field_here>), NULL) from
> table_with_clob_field
>
> it runs fine.
>
> This doesn't seem like bug, more like a feature request.
> Before I contact Tech Support I wanted to hear your opinions.
> Madison?
> Anyone?
>
> Thanks.
>
>
Madison, thank you very much. I'll try and report the results. "Madison Pruet" <mpruet@comcast.net> wrote in message news:45663C60.1020808@comcast.net... > We didn't have ways to implement the UDR on all data types, but I thought > that we had implemented the checksums for blobs and clobs, but not byte > and text columns. > > That said - to do the checksum for blobs and bytes, you would need to do > something like the following.
> We didn't have ways to implement the UDR on all data types, but I thought
> that we had implemented the checksums for blobs and clobs, but not byte
> and text columns.
Madison, (looking now at the original source code downloaded from
developerworks) you did implement smart blob checksums.
There was just this sql portion for routine registration missing in the
accompanying sql file.
Maybe I've had an old version downloaded? Don't know. Problem solved.
Thanks.
> ---------------------------------------------------------
> create function checksum(p1 blob, p2 integer)
> RETURNS integer
> with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE)
> EXTERNAL NAME "$INFORMIXDIR/udrs/checksum.so(sblob_checksum)"
> LANGUAGE C;>
> create function checksum(p1 clob, p2 integer)
> RETURNS integer
> with (NOT VARIANT, HANDLESNULLS, PARALLELIZABLE)
> EXTERNAL NAME "$INFORMIXDIR/udrs/checksum.so(sblob_checksum)"
> LANGUAGE C;>
> -----------------------------------------------------------
> Blobs and clobs can use the same checksum routine because internally they
> are pretty much the same thing.
>