© 2001 International Business Machines Corporation. All rights reserved.
The oncheck utility lets you monitor smart blob
spaces (sbspaces) and monitor the smart blobs stored in those sbspaces,
but it is difficult to associate oncheck output
with a specific smart blob. The sblob_info DataBlade module creates
smart blob metadata and constructor UDRs to make it easier to monitor a
specific smart blob and to create/update test smart blobs.
The sblob_info metadata UDRs extract storage information about a smart blob:
| SblobDebug | Outputs debug messages to a trace file. |
| SblobStatSize | Returns the size of the smart blob. |
| SblobSbspace | Returns the name of the sbspace in which the smart blob is stored. |
| SblobMaxSize | Returns the maximum size specified for the smart blob. |
| SblobEstSize | Returns the estimated size specified for the smart blob. |
| SblobExtSize | Returns the smart blob extent size in kilobytes. |
| SblobLog | Returns if the user data portion of the smart blob
is logged ("t") or not
("f"). |
| SblobRefCount | Returns the reference count for a smart blob. |
The sblob_info constructor UDRs create and update test smart blobs:
| SblobCreate | Creates a smart blob, allows specifying sbspace, size, logging, estimated size, and maximum size. |
| SblobUpdate | Updates a smart blob, allows append or replace. |
A smart blob created or updated with SblobCreate() and
SblobUpdate() does not store anything interesting; the
underlying code simply fills the smart blob space with
Xs. The purpose is to test the creation of
smart blobs with a variety of storage and/or logging characteristics, and
append to or overwrite those smart blobs, then:
-
Monitor the affects of the smart blob operation on sbspace and logical log space usage with the sblob_info metadata UDRs and the
oncheck -pSandonstat -lcommands. -
Verify that the end result is what was intended.
Finally, sblob_info targets:
-
Developers who create smart blobs in a DataBlade module as part of opaque type or access method development.
For example, one common problem is a DataBlade module creates smart blobs in the default sbspace instead of in the sbspace specified for a column in a table. The source code for SblobCreate() shows how to set storage characteristics, and the metadata functions verify the result.
-
Database administrators and end users who want to use the metadata functions to monitor a specific smart blob.
To build and run sblob_info.1.5, you need a C compiler to build the shared object, and IDS 9.2x installed on your system.
sblob_info.1.5 was tested with the software releases listed below:
SUN:
-
Solaris 2.7
-
IDS 9.20.UC2
-
SUNpro C Compiler
NT:
-
WINNT 4.0 with Service Pack 5
-
IDS 9.20.TC1
-
Microsoft Visual C++ 6.0
Download the sblob_info.1.5.tar.Z compressed tar archive. (See "Download.")
Uncompress it:
uncompress sblob_info.1.5.tar.Z |
Extract the tar archive:
tar xvf sblob_info.1.5.tar |
The distribution is extracted into a hierarchy under a diretory named sblob_info.1.5. The directory contents are summarized in the table below.
| README | This file. |
| demo/ | Subdirectory with a demo script (main.sh), output from the script (demo.std), and sample tracefile output. |
| scripts/ | SQL registration scripts. The contents of this directory should be copied to: $INFORMIXDIR/extend/sblob_info.1.5 |
| src/ | Source code for the UDRs. |
| Build a Solaris shared object: setenv TARGET $INFORMIXDIR/incl/dbdk/makeinc.solaris make -f sblob_infoU.mak server >& compile.log Review the compile.log file for any symbols that will not be resolved later by the server, then install the shared object: cp solaris-sparc/sblob_info.bld $INFORMIXDIR/extend/sblob_info.1.5 | |
Build an NT DLL:
| |
| sblob_info.ibs | BladeSmith project generated with BladeSmith version 4.00.TC1. |
The example comes ready made for Solaris 2.7 and for WinNT 4.0. If you are
not on Solaris or NT, you must cd into the
source code directory and recompile for your platform.
CURRENTDIR in the instructions below refers to the root location for this DataBlade module distribution.
Login as user informix.
Unix:
mkdir $INFORMIXDIR/extend/sblob_info.1.5 cd $CURRENTDIR cp ./src/solaris-sparc/sblob_info.bld $INFORMIXDIR/extend/sblob_info.1.5 cp ./scripts/* $INFORMIXDIR/extend/sblob_info.1.5 |
NT (using MKS):
mkdir $INFORMIXDIR/extend/sblob_info.1.5 cd $CURRENTDIR cp ./src/WinNT-i386/sblob_info.bld $INFORMIXDIR/extend/sblob_info.1.5 cp ./scripts/* $INFORMIXDIR/extend/sblob_info.1.5 |
Register the DataBlade module in a database
At the UNIX prompt, login as user informix (or grant your userid resource privileges) and register the DataBlade module:
blademgr shm> register sblob_info.1.5 demodb |
If registration fails, check the following files:
-
/tmp/blademgr/*.log
-
$INFORMIXDIR/online.log
You can also run BladeManager from NT.
If you have not already created a smart blob space yet:
-
Create a smart blob space with the
onspaces -c -Scommand, which is described in the Informix Administrator's Reference. -
Set the
SBSPACENAMEonconfig parameter to the newly created smart blob space.
The usage examples in this section assume the following table create and inserts:
create table sblob_test (description lvarchar, blob_column blob);
insert into sblob_test values |
Note that on NT you need to modify the paths to the standard C include files to point to the copies in your VC++ installation.
This DataBlade module uses the built-in __myErrors__ trace class for debug messages. SblobDebug() sets the trace level of __myErrors__.
Trace messages get output to /tmp/session_id.trc if the trace level
for the trace class is greater than the threshold in the
DPRINTF statement in the source code. So far,
all functions specify a threshold of 20. So calling SblobDebug()
with a value >= 20 causes messages to be output to the trace file.
SblobDebug (integer) returns void
execute procedure SblobDebug(30); |
SblobStatSize (mi_lo_stat_size)
SblobStatSize() calls mi_lo_stat_size()
to determine the size of a smart blob.
SblobStatSize (blob) returns int8
Above, we inserted the stdio.h and stdlib.h include files into the sblob_test table. In a DB-Access window execute the following query:
select description, blob_column, SblobStatSize(blob_column) |
In another window, do the following commands at the operating system prompt to list the file size:
ls -l /usr/include/stdio.h |
(Note that on NT you'll need to modify the path to the standard C include files to point to the copies in your VC++ installation.)
Do the sizes match? (They should.) You can also check the size of each
smart blob with the oncheck command:
oncheck -pS sbspace |
The size is output in the Size (Bytes)
field.
SblobSbspace (mi_lo_specget_sbspace)
SblobSbspace() calls
mi_lo_specget_sbspace() to get the name of the
smart blob space in which a smart blob is stored.
SblobSbspace (blob) returns lvarchar
In a DB-Access window execute the following query:
select description, blob_column, SblobSbspace(blob_column) |
This example is more interesting if you do not use the default smart blob
space defined by the SBSPACENAME parameter in
the onconfig file.
SblobMaxSize() calls
mi_lo_specget_maxbytes() to get the maximum
size specified for the smart blob.
SblobMaxSize (blob) returns int8
In a DB-Access window execute the following query:
select description, blob_column, SblobMaxSize(blob_column) |
If no maximum size has been set for the smart blob, the result will be
-1. You can verify the result with the
oncheck command:
oncheck -pS sbspace
The max size is output in the Size Limit
field.
SblobEstSize() calls
mi_lo_specget_estbytes() to get the estimated
size specified for the smart blob. The server preallocates space of this
size when the smart blob is created, and subsequent updates to the smart
blob fill up this space. Once this space is filled, the server adds new
extents as needed.
SblobEstSize() (blob) returns int8
In a DB-Access window execute the following query:
select description, blob_column, SblobEstSize(blob_column) |
Currently, if no estimated size has been established, the value returned is
the actual size. You may notice, however, that the
oncheck command outputs a NULL in the
Total Estimated Size field in some
releases:
oncheck -pS sbspace
SblobExtSize() calls
mi_lo_specget_extsz() to get the extent size
(EXTENT_SIZE) specified for the smart blob.
SblobExtSize (blob) returns integer
In a DB-Access window execute the following query:
select description, blob_column, SblobExtSize(blob_column) |
A return value of 0 means that an EXTENT_SIZE
hint was not provided when the sbspace was created. In this case, the
system will figure out the extent size itself.
SblobLog()
mi_lo_specget_flags()
mi_lo_specget_flags()
SblobLog (blob) returns boolean
In a DB-Access window execute the following query:
select description, blob_column, SblobLog(blob_column) |
A return value of "t" means that the user data
is logged; "f" means it is not logged.
SblobCreate() creates a smart blob, and allows specifying some smart blob attributes.
The purpose of this function is to create smart blobs with different
characteristics, which can be monitored with functions in this blade as
well as the oncheck and
onstat -l commands. One of the goals is to
understand and demonstrate the affects of smart blob operations on smart
blob spaces and logical logs.
SblobCreate (sbspace, size, logging, estbytes, maxbytes) returns blob
| sbspace | String containing the name of the smart blob space,
which gets passed to the call to
mi_lo_specset_sbspace(). If "default"
is specified, mi_lo_specset_sbspace()
is not called, causing the smart blob to be created in the default
SBSPACENAME defined in the onconfig
file. SblobCreate() does not check the validity of sbspace
name. |
| size | int8 value >= 0, specifying the length (in
bytes) of the smart blob to be created. This space gets filled
with Xs. |
| logging | String containing "log" or "nolog"; any other value
causes an error to be raised. The parameter sets the user data
logging mode (LO_LOG or
LO_NOLOG) for the call to
mi_lo_specset_flags(). |
| estbytes | int8 value specifying the estimated size of the smart
blob for the call to
mi_lo_specset_estbytes(). If set to
<= 0,
mi_lo_specset_estbytes() is not called.
|
| maxbytes | int8 value specifying the maximum size of the smart
blob for the call to
mi_lo_specset_maxbytes(). If set to
<= 0,
mi_lo_specset_maxbytes() is not called.
|
Warning: setting any sizes to 2,147,483,647 or greater has not been tested.
In a DB-Access window execute the following query, while checking with
oncheck -pS in another window:
insert into sblob_test values
('create a 1500 byte sblob',
SblobCreate("default", 1500, "nolog", -1, -1));
select description,
SblobStatSize(blob_column) as statsize,
SblobSbspace(blob_column) as sbspace,
SblobEstSize(blob_column) as estimated_size,
SblobMaxSize(blob_column) as max_size
from sblob_test
where description="create a 1500 byte sblob";
insert into sblob_test values
('1024 byte sblob',
SblobCreate("default", 1024, "log", 2048, 4096));
select description,
SblobStatSize(blob_column) as statsize,
SblobSbspace(blob_column) as sbspace,
SblobEstSize(blob_column) as estimated_size,
SblobMaxSize(blob_column) as max_size
from sblob_test
where description="1024 byte sblob"; |
SblobUpdate() updates a smart blob, and allows appending to or replacing (truncating first) the previous contents.
One of the goals is to understand and demonstrate the affects of smart blob updates on smart blob spaces and logical logs.
SblobUpdate (blob, size, options) returns integer
| blob | Smart blob handle. |
| size | int8 value >= 0 specifying the length (in
bytes) of the update. This space is filled with
Xs. |
| options | String containing "truncate" or "append"; any other
value causes an error to be raised. If the parameter is set to
"truncate", mi_lo_open() flags are set
to MI_LO_WRONLY | MI_LO_TRUNC. If
the parameter is set to "append",
mi_lo_open() is called with
MI_LO_WRONLY. |
In a DB-Access window execute the following query, while checking with
oncheck -pS in another window:
insert into sblob_test values
('foo', SblobCreate("default", 1024, "log", 2048, 4096));
-- Add 2000 bytes.
select SblobUpdate(blob_column, 2000, "append")
from sblob_test
where description="foo";
-- The resulting sblob should be 3024 bytes.
select description,
SblobStatSize(blob_column) as statsize,
SblobSbspace(blob_column) as sbspace,
SblobEstSize(blob_column) as estimated_size,
SblobMaxSize(blob_column) as max_size,
SblobLog(blob_column) as logged from
sblob_test where description="foo";
-- Replace with 1800 bytes. select SblobUpdate(blob_column, 1800, "truncate")
from sblob_test
where description="foo";
-- The resulting sblob should be 1800 bytes.
select description,
SblobStatSize(blob_column) as statsize,
SblobSbspace(blob_column) as sbspace,
SblobEstSize(blob_column) as estimated_size,
SblobMaxSize(blob_column) as max_size,
SblobLog(blob_column) as logged
from sblob_test
where description="foo"; |
SblobRefCount() returns an integer that indicates how many times a particular blob is referenced by LO handles stored in database tables.
SblobRefCount (blob) returns integer
In a DB-Access window create a table with a blob column and insert a row:
create table sblob_tab(blob_column blob);
insert into sblob_tab values
( FileToBlob('/usr/include/stdio.h', 'server'));
select SblobExtSize(blob_column) from sblob_tab; |
Note that on NT you'll need to modify the path to the standard C include files to point to the copies in your VC++ installation.
Since this sblob is used only once, the value "1" should be returned.
Now create a temp table with a blob column that references the same sblob:
select blob_column from sblob_tab into temp sblob_temp_tab; |
Check the refcount again: It should rise to "2".
select SblobExtSize(blob_column) from sblob_tab; |
Version 1.0
Implements the first three UDRs (SblobDebug, SblobStatSize, and SblobSbspace).
Version 1.1
Adds the next six UDRs (SblobMaxSize, SblobEstSize, SblobExtSize, SblobLog, SblobCreate, and SblobUpdate).
Version 1.1 fix 1/16/98
Source code replaces calls to ifx_int8toint()
with ifx_int8tolong().
-
ifx_int8toint()corresponds to SQLSMALLINT/mi_smallint( -32767 to +32767 ) -
ifx_int8tolong()corresponds to SQLINT/mi_integer( -2,147,483,647 to +2,147,483,647 ) -
The next major release will replace all sizes with SQL
INT8/mi_int8.
Version 1.2
Implements SblobRefCount.
Version 1.3
Rebuilds for server release 9.2 and DBDK version 4.00.
Version 1.4
Added pre-compiled shared object for NT.
Version 1.5
Changed program variables associated with size to use int8. This will allow sblob sizes > 2GB.
| Description | Name | Size | Download method |
|---|---|---|---|
| Compressed tar archive | sblob_info.1.5.tar.Z | 204KB |
FTP
|
Information about download methods
- Build your next
development project with
IBM
trial software,
available for download directly from developerWorks.
- developerWorks Information Management zone:
Learn more about DB2. Find technical documentation, how-to articles,
education, downloads, product information, and more.




