Are COMPRESS() / DECOMPRESS() only intended for use within a SQLA database or are the algorithms used compatible with external utilities? In other words, should I expect the output zip archive of this process to be accessible by Windows Explorer, 7zip etc:

create variable uncomp long binary;
create variable comp long binary;
set uncomp = xp_read_file('c:\temp\stuff.txt');
set comp = compress(uncomp,'zip');
call xp_write_file('c:\temp\stuff.zip',comp);

I find I can't read that file outside SQLA (nor if I use the gzip algorithm). Am I missing something obvious (wouldn't be the first time!)?

The docs say "Zip is a widely supported compression algorithm. Gzip is compatible with the gzip utility on Unix, whereas the zip algorithm is not. " I'm doing my gzip testing on Windows with 7zip, not on Linux/Unix, but other gzip archives seem to work fine.

v17.0.9.4838

asked 13 Nov, 09:16

Justin%20Willey's gravatar image

Justin Willey
7.2k123159228
accept rate: 21%

You certainly have noticed Mark's old response here, haven't you?

Note, I'm just adding the link, I have not tested anything related to compressing files at all...

(13 Nov, 10:38) Volker Barth

John is correct that we use a custom header but only if no compression algorithm is given. If you give 'zip' or 'gzip' as an algorithm, we do not use the header, making the compression compatible with outside tools.

However the name of the 'zip' algorithm is a bit misleading - it does not make the output compatible with Windows .zip files. This algorithm simply compresses data (i.e. a single file) while .zip files are a compressed archive format. If you use 'gzip' as the algorithm instead of 'zip', Windows tools should be able to decompress the data.

permanent link

answered 13 Nov, 10:56

Graeme%20Perrow's gravatar image

Graeme Perrow
8.9k375115
accept rate: 53%

Thanks Graeme - that all makes sense.

(13 Nov, 11:27) Justin Willey

I believe that although we use the standard algorithms, we add a custom header to identify encryption type and/or remove some of the headers that the file-based utilities would add. For example, zip files contain a directory of files included in the archive and that would be very expensive to include on a per-value basis.

permanent link

answered 13 Nov, 10:09

John%20Smirnios's gravatar image

John Smirnios
9.5k381121
accept rate: 39%

Thanks - yes that makes sense about the folder stuff being the difference.

(13 Nov, 11:28) Justin Willey
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×114
×21
×12

question asked: 13 Nov, 09:16

question was seen: 54 times

last updated: 13 Nov, 11:28