Db2 APIs for using compression with backup and restore operations
Db2 defines a set of API prototypes that provide a general purpose interface for compression and decompression that can be used by many vendors. These APIs are to be provided by the vendor in a shared library on Linux® and UNIX systems, or DLL on the Windows operating system. When the APIs are invoked by Db2, the shared library or DLL specified by the calling backup or restore routine is loaded and the APIs provided by the vendor are called to perform the required tasks.
Operational overview
- InitCompression - Initialize the compression library
- GetSavedBlock - Get vendor block for backup image
- Compress - Compress a block of data
- GetMaxCompressedSize - Estimate largest possible buffer size
- TermCompression - Terminate the compression library
- InitDecompression - Initialize the decompression library
- Decompress - Decompress a block of data
- TermDecompression - Terminate the decompression library
Db2 will provide the definition for the COMPR_DB2INFO structure; the vendor will provide definitions for each of the other structures and APIs for using compression with backup and restore. The structures, prototypes, and constants are defined in the file sqlucompr.h, which is shipped with Db2 database products.
Db2 will call these APIs, and they should be provided by the vendor product in a shared library on Linux and UNIX systems, or in a DLL on the Windows operating system.
Sample calling sequence
InitCompression
followed by 0 to 1
GetMaxCompressedSize
Compress
followed by 1
TermCompress
InitDecompression
followed by 1 to n Decompress
followed by 1 TermCompression
Compression plug-in interface return codes
The following are the return codes that the APIs might return. Except where specified, Db2 will terminate the backup or restore when any non-zero return code is returned.
SQLUV_OK
0
Operation succeeded
SQLUV_BUFFER_TOO_SMALL
100
Target buffer is too small. When indicated on backup, the tgtAct field shall indicate the estimated size required to compress the object. Db2 will retry the operation with a buffer at least as large as specified. When indicated on restore, the operation will fail.
SQLUV_PARTIAL_BUFFER
101
A buffer was partially compressed. When indicated on backup, the srcAct field shall indicate the actual amount of data actually compressed and the tgtAct field shall indicate the actual size of the compressed data. When indicated on restore, the operation will fail.
SQLUV_NO_MEMORY
102
Out of memory
SQLUV_EXCEPTION
103
A signal or exception was raised in the code.
SQLUV_INTERNAL_ERROR
104
An internal error was detected.
The difference between SQLUV_BUFFER_TOO_SMALL and SQLUV_PARTIAL_BUFFER is that when SQLUV_PARTIAL_BUFFER is returned, Db2 will consider the data in the output buffer to be valid.