Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Smart Blob Information DataBlade Module (sblob_info.1.5)

Jean T. Anderson, developerWorks Contributing Author, IBM, Software Group
Jean Anderson is a Senior Engineer with IBM.

Summary:  Creates an Informix DataBlade with UDRs that create and manage smart large objects. Includes C source code.

Date:  19 Jun 2000
Level:  Introductory

Activity:  2468 views
Comments:  

© 2001 International Business Machines Corporation. All rights reserved.

Overview

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 -pS and onstat -l commands.

  • 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.


Required Software

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


Getting Started

Download the Distribution

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.

READMEThis 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:
  • Open the sblob_info.ibs project file in Bladesmith, using DBDK 4.00

  • Select "Tools", "MSDEV". This will start Visual C++ and open the sblob_info project. Note that you must have version 6 of Visual C++.

  • Select "Build", and "Rebuild All" in VC++.

After building the DLL, install the shared object:
  • Copy WinNT-i386/sblob_info.bld to $INFORMIXDIR/extend/sblob_info.1.5

  • Using the WinNT "Explore" utility, highlight $INFORMIXDIR/extend/sblob_info.1.5/sblob_info.bld, select "File" and "Properties", and set the "Read Only" property.

sblob_info.ibsBladeSmith project generated with BladeSmith version 4.00.TC1.

Install the DataBlade module

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.

Create a Smart Blob Space

If you have not already created a smart blob space yet:

  • Create a smart blob space with the onspaces -c -S command, which is described in the Informix Administrator's Reference.

  • Set the SBSPACENAME onconfig parameter to the newly created smart blob space.


User-Defined Routines (UDRs)

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
('stdio.h: standard i/o header', FileToBlob('/usr/include/stdio.h', 'server') ); insert into sblob_test values
('stdlib.h: standard library header', FileToBlob('/usr/include/stdlib.h', 'server') );

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.


SblobDebug

Description

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.

Syntax

SblobDebug (integer) returns void

Example

  execute procedure SblobDebug(30);  


SblobStatSize (mi_lo_stat_size)

Description

SblobStatSize() calls mi_lo_stat_size() to determine the size of a smart blob.

Syntax

SblobStatSize (blob) returns int8

Example

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)  
from sblob_test;

In another window, do the following commands at the operating system prompt to list the file size:

  ls -l /usr/include/stdio.h
ls -l /usr/include/stdlib.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)

Description

SblobSbspace() calls mi_lo_specget_sbspace() to get the name of the smart blob space in which a smart blob is stored.

Syntax

SblobSbspace (blob) returns lvarchar

Example

In a DB-Access window execute the following query:

  select description, blob_column, SblobSbspace(blob_column)
from sblob_test;

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

Description

SblobMaxSize() calls mi_lo_specget_maxbytes() to get the maximum size specified for the smart blob.

Syntax

SblobMaxSize (blob) returns int8

Example

In a DB-Access window execute the following query:

  select description, blob_column, SblobMaxSize(blob_column)
from sblob_test;

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

Description

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.

Syntax

SblobEstSize() (blob) returns int8

Example

In a DB-Access window execute the following query:

  select description, blob_column, SblobEstSize(blob_column)
from sblob_test;

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

Description

SblobExtSize() calls mi_lo_specget_extsz() to get the extent size (EXTENT_SIZE) specified for the smart blob.

Syntax

SblobExtSize (blob) returns integer

Example

In a DB-Access window execute the following query:

  select description, blob_column, SblobExtSize(blob_column)
from sblob_test;

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

Description

SblobLog() mi_lo_specget_flags()

mi_lo_specget_flags()

Syntax

SblobLog (blob) returns boolean

Example

In a DB-Access window execute the following query:

  select description, blob_column, SblobLog(blob_column)
from sblob_test;

A return value of "t" means that the user data is logged; "f" means it is not logged.


SblobCreate

Description

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.

Syntax

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.

Example

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

Description

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.

Syntax

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.

Example

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

Description

SblobRefCount() returns an integer that indicates how many times a particular blob is referenced by LO handles stored in database tables.

Syntax

SblobRefCount (blob) returns integer

Example

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;  


Revision History

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 SQL SMALLINT / mi_smallint ( -32767 to +32767 )

  • ifx_int8tolong() corresponds to SQL INT / 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.



Download

DescriptionNameSizeDownload method
Compressed tar archivesblob_info.1.5.tar.Z204KB FTP | HTTP

Information about download methods


Resources

About the author

Jean Anderson is a Senior Engineer with IBM.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=13559
ArticleTitle=Smart Blob Information DataBlade Module (sblob_info.1.5)
publish-date=06192000
author1-email=jander@us.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers