The string_output_gz_compress compresses its string_output argument using the gzip algorithm and writes the result to another string_output given as an argument. When successful, the number of bytes written to str_out_out is returned.
INTEGER number of bytes written to str_out_out
Test if the gzip implementation works.
create procedure
gz_test_1 (in fname varchar)
{
declare dta, dta_2, res any;
declare len integer;
res := string_output ();
dta_2 := string_output ();
dta := file_to_string_output (fname);
result_names (len);
-- send length of input to client
result (length (dta));
-- compress and return compressed size.
result (string_output_gz_compress (dta, res));
gz_uncompress (string_output_string (res), dta_2);
if (md5 (dta) <> md5 (dta_2))
signal ('SNAFU', 'GZIP algorithm implementation is faulty.');
result (length (dta));
end_result();
}
;
SQL> gz_test_1 ('tmp/test.dat');
len
INTEGER
_______________________________________________________________________________
11689
2477
11689
3 Rows. -- 11 msec.