INFORMIX
DataBlade API Programmer's Manual
Chapter 3: Handling Smart Large Objects
Home Contents Index Master Index New Book

Using the Smart-Large-Object Interface

The Universal Server smart-large-object interface allows you to access the data of a smart large object in much the same way as you would access an operating-system file in the UNIX or Windows NT operating systems. The interface provides smart-large-object functions and smart-large-object data structures.

The milo.h header file defines the functions and data structures of the smart-large-object interface. The mi.h header file automatically includes the milo.h header file. You must include either mi.h or milo.h in any DataBlade API function that calls a smart-large-object function or declares one of the smart-large-object data structures.

Sections of this chapter describe how to use the smart-large-object interface to perform the following operations on a smart large object.
Smart-Large-Object Operation For More Information

Create a new smart large object

page 3-32

Access data in an existing smart large object

page 3-60

Modify an existing smart large object

page 3-72

Obtain status information about an existing smart large object

page 3-74

Delete a smart large object

page 3-80

Tip: The DataBlade API also supports the Illustra large-object interface for backward compatibility with Illustra products.

Smart-Large-Object Data Structures

The INFORMIX-Universal Server smart-large-object interface provides data structures that store information about a smart large object. Figure 3-4 summarizes the data structures of the smart-large-object interface.

Figure 3-4
Data Structures of the Smart-Large-Object Interface
Smart-Large-Object Data Structure Data Type Description

The LO-specification structure

MI_LO_SPEC

Holds storage characteristics for a smart large object

The LO handle

MI_LO_HANDLE

Identifies the location of the smart large object; analogous to the filename of an operating-system file.

The LO file descriptor

MI_LO_FD

Identifies an open smart large object; analogous to the file descriptor of an operating-system file.

The LO-status structure

MI_LO_STAT

Holds status information about a smart large object

These structures are all opaque to a DataBlade routine; that is, you do not access their fields directly but instead use accessor functions that the smart-large-object interface provides.

The LO-Specification Structure

The LO-specification structure, MI_LO_SPEC, defines the storage characteristics for an existing or a new smart large object. The storage characteristics provide information about features of the smart large object and how to store them on disk. For a description of the storage characteristics available, see "Storage Characteristics".

To access an LO-specification structure in a DataBlade routine, declare a pointer to an MI_LO_SPEC structure. For example, the following line shows the valid syntax of a variable that accesses an LO-specification structure:

Declaration of a flat LO-specification structure generates a compile error. The following line shows invalid syntax for an LO-specification structure:

The milo.h header file defines the MI_LO_SPEC data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade routines that access this structure. For information on how to use an LO-specification structure, see "Obtaining the LO-Specification Structure".

The LO Handle

The LO handle, MI_LO_HANDLE, serves as a reference to a smart large object. It is analogous to the filename of an operating-system file in that it is a unique identifier of a smart large object. It contains encoded information about the smart large object, such as its physical disk location and other security-related information. Once a smart large object is created, an associated LO handle is a valid reference for the life of that smart large object.

To access an LO handle in a DataBlade routine, declare it in one of the following ways:

    When you declare a flat MI_LO_HANDLE structure, you do not need to allocate memory for it. This flat structure is useful when you need to embed an LO handle within an opaque data type.

The milo.h header file defines the MI_LO_HANDLE data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade routines that access this handle. For information on how to use an LO handle, see "Initializing an LO Handle and LO File Descriptor" and "Selecting the LO Handle".

The LO File Descriptor

The LO file descriptor, MI_LO_FD, is a reference to an open smart large object. An LO file descriptor is similar to a file descriptor for an operating-system file. It is an integer number that serves as a transient descriptor for performing I/O on the data of the smart large object. It provides the following information about an open smart large object:

    When you first open a smart large object, the seek position is at byte zero (0).

To access an LO file descriptor in a DataBlade routine, declare a variable with the MI_LO_FD data type. For example, the following line declares the variable my_lofd that is an LO file descriptor:

The milo.h header file defines the MI_LO_FD data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade routines that access this handle.

Tip: Other smart-large-object data structures require that you declare a pointer to them because the DataBlade API handles memory allocation for these structures. However, you can directly declare an LO file descriptor.

For information on how to use an LO file descriptor, see "Initializing an LO Handle and LO File Descriptor".

The LO-Status Structure

The LO-status structure, MI_LO_STAT, contains the status information for an existing smart large object. To access an LO-status structure in a DataBlade routine, declare a pointer to an MI_LO_STAT structure. For example, the following line declares the variable mystat that points to an LO-specification structure:

Declaration of a flat LO-status structure generates a compile error. The following line shows invalid syntax for an LO-status structure:

The milo.h header file defines the MI_LO_STAT data type. Therefore, you must include the milo.h (or mi.h) file in DataBlade routines that access this structure. For information on how to allocate and use an LO-status structure, see "Obtaining the Status of a Smart Large Object".

Smart-Large-Object Functions

The INFORMIX-Universal Server smart-large-object interface includes functions that provide the following operations on a smart large object:

Most of the smart-large-object functions begin with the string mi_lo_. Chapter 12, "DataBlade API Function Descriptions," contains an alphabetical list of all DataBlade API functions, including the smart-large-object functions.

Smart-Large-Object Creation

The smart-large-object creation functions create a new smart large object, open it, and return a valid LO handle and LO file descriptor for it. Figure 3-5 lists the smart-large-object creation functions.

Figure 3-5
Smart-Large-Object Creation Functions
Smart-Large-Object Creation Function Description

mi_lo_create()

Creates a new, empty smart large object

mi_lo_copy()

Creates a new smart large object that is a copy of an existing smart large object

mi_lo_expand()

Creates a new smart large object from existing
multirepresentational data

mi_lo_from_file()

Creates a new smart large object from data in an operating-system file

For more information on how to use the smart-large-object creation functions, see "Creating a Smart Large Object".

Smart-Large-Object I/O

The INFORMIX-Universal Server smart-large-object interface includes functions that provide basic file operations such as create, open, seek, read, write, alter, and truncate. These functions bypass the query processor, executor, and optimizer, and give the application direct access to a smart large object. These functions use an LO file descriptor to identify the open smart large object.

Figure 3-6 shows the basic file-like operations on a smart large object along with the smart-large-object function that performs them and the analogous operating-system system calls for file operations.

Figure 3-6
Main DataBlade API Functions of the Smart-Large-Object Interface
Smart-Large-Object Operation Smart-Large-Object Function Operating-System
System Call

Open the smart large object that the LO handle identifies: the open operation generates an LO file descriptor for the smart large object.

mi_lo_open()

open()

Seek to the desired LO seek position to begin a
read or write operation.

mi_lo_seek()

seek()

Obtain the current LO seek position.

mi_lo_tell()

tell()

Perform the read or write operation for the
specified number of bytes.

mi_lo_read(), mi_lo_readwithseek(), mi_lo_write(), mi_lo_writewithseek()

read(), write()

Obtain status information about a particular
smart large object.

mi_lo_stat()

stat()

Truncate smart-large-object data at a specified location.

mi_lo_truncate()

truncate()

Close the smart large object and deallocate the
LO file descriptor.

mi_lo_close()

close()

For more information, see "Opening a Smart Large Object".

Manipulation of LO Handles

The following table shows the smart-large-object functions that act on an LO handle, not on the smart large object that it represents.

(1 of 2)

DataBlade API Function Purpose

mi_get_lo_handle()

Obtains an LO handle from a user-defined buffer

mi_lo_alter()

Alters the storage characteristics of the smart large object that the LO handle identifies

mi_lo_copy()

Copies the contents of a smart large object (that an LO handle identifies) into a new smart large object and initializes the LO handle of the new smart large object

mi_lo_create()

Creates a new smart large object and initializes its LO handle

mi_lo_decrefcount()

Decrements the reference count of the smart large object that the LO handle identifies

mi_lo_expand()

Copies multirepresentational data into a new smart large object and initializes the LO handle

mi_lo_filename()

Returns the name of the file where the mi_lo_to_file() function would store the smart large object that the LO handle identifies

mi_lo_from_buffer()

Copies a specified number of bytes from a user-defined buffer into a smart large object that the LO handle identifies

mi_lo_from_file()

Copies the contents of an operating-system file to a smart large object that the LO handle identifies

mi_lo_from_string()

Converts an LO handle from its text representation to its binary representation

mi_lo_increfcount()

Increments the reference count of the smart large object that the LO handle identifies

mi_lo_invalidate()

Marks an LO handle as invalid

mi_lo_lolist_create()

Converts an array of LO handles into an MI_LO_LIST structure

mi_lo_open()

Opens the smart large object that the LO handle identifies

mi_lo_ptr_cmp()

Compares two LO handles to see if they identify the same smart large object

mi_lo_release()

Releases resources held by a temporary smart large object, including its LO handle

mi_lo_to_buffer()

Copies a specified number of bytes from a smart large object that the LO handle identifies into a user-defined buffer

mi_lo_to_file()

Copies the smart large object that the LO handle identifies to an operating-system file

mi_lo_to_string()

Converts an LO handle from its binary representation to its text representation

mi_lo_validate()

Checks whether an LO handle is valid

mi_put_lo_handle()

Puts an LO handle into a user-defined buffer

Important: The LO handle, MI_LO_HANDLE, is an opaque structure to DataBlade routines. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_HANDLE will not change. Therefore, to create portable code, use the appropriate DataBlade API function to use this structure.

For more information on how to use these functions, see "Obtaining an LO Handle".

Smart-Large-Object Storage Characteristics

The following table shows the smart-large-object functions that access the LO-specification structure.

(1 of 2)

DataBlade API Function Purpose

mi_lo_alter()

Alters the storage characteristics of an existing smart large object

mi_lo_colinfo_by_ids()

Updates the LO-specification structure with the column-level storage characteristics for a column identified by a row descriptor

mi_lo_colinfo_by_name()

Updates the LO-specification structure with the column-level storage characteristics for a column identified by name

mi_lo_copy()

Copies the contents of the smart large object into a new smart large object, whose storage characteristics the LO-specification structure contains

mi_lo_create()

Creates a new smart large object that has the storage characteristics in the LO-specification structure

mi_lo_expand()

Copies multirepresentational data into a new smart large object, whose storage characteristics the LO-specification structure contains

mi_lo_from_file()

Copies the contents of an operating-system file to a smart large object, whose storage characteristics the LO-specification structure contains

mi_lo_spec_free()

Frees the resources of the LO-specification structure

mi_lo_spec_init()

Allocates and initializes an LO-specification structure

mi_lo_specget_estbytes()

Accessor function to get the estimated number of bytes from the LO-specification structure

mi_lo_specget_extsz()

Accessor function to get the allocation extent size from the LO-specification structure

mi_lo_specget_flags()

Accessor function to get the attributes flag from the LO-specification structure

mi_lo_specget_maxbytes()

Accessor function to get the maximum number of bytes from the LO-specification structure

mi_lo_specget_sbspace()

Accessor function to get the name of the sbspace from the LO-specification structure

mi_lo_specset_estbytes()

Accessor function to set the estimated number of bytes in the LO-specification structure

mi_lo_specset_extsz()

Accessor function to set the allocation extent size in the LO-specification structure

mi_lo_specset_flags()

Accessor function to set the attribute flags in the LO-specification structure

mi_lo_specset_maxbytes()

Accessor function to set the maximum number of bytes in the LO-specification structure

mi_lo_specset_sbspace()

Accessor function to set the name of the sbspace in the LO-specification structure

mi_lo_stat_cspec()

Returns a pointer to the LO-specification structure that contains the storage characteristics obtained from the LO-status structure of an existing smart large object

Important: The LO-specification structure, MI_LO_SPEC, is an opaque structure to DataBlade routines. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_SPEC will not change in future releases. Therefore, to create portable code, always use the LO-specification accessor functions to obtain and store values in this structure.

For more information on how to use these functions, see "Obtaining the LO-Specification Structure" and "Choosing Storage Characteristics".

Smart-Large-Object Status

The following table shows the smart-large-object functions that access the LO-status structure.

DataBlade API Function Purpose

mi_lo_stat()

Allocates and initializes an LO-status structure with status information of an open smart large object

mi_lo_stat_atime()

Accessor function to get the last-access time

mi_lo_stat_cspec()

Accessor function to get the storage characteristics

mi_lo_stat_ctime()

Accessor function to get the last-change time

mi_lo_stat_free()

Frees the resources of the LO-status structure

mi_lo_stat_mtime()

Accessor function to get the last-modification time

mi_lo_stat_refcnt()

Accessor function to get the reference count

mi_lo_stat_size()

Accessor function to get the size of smart large object

Important: The LO-status structure, MI_LO_STAT, is an opaque structure to DataBlade routines. Do not access its internal structure directly. Informix does not guarantee that the internal structure of MI_LO_STAT will not change in future releases. Therefore, to create portable code, always use the LO-status accessor functions to obtain values from this structure.

For more information on how to use these functions, see "Obtaining the Status of a Smart Large Object".

Smart Large Objects to and from Operating-System Files

The following table shows the smart-large-object functions that move smart large objects to and from operating-system files.

DataBlade API Function Purpose

mi_file_to_file()

Copies the contents of one operating-system file to another

mi_lo_from_file()

Copies the contents of an operating-system file to a new smart large object

mi_lo_from_file_by_lofd()

Copies the contents of an operating-system file to an existing smart large object

mi_lo_to_file()

Copies the contents of a smart large object to a new
operating-system file

For more information on how to use these functions, see "Using Operating-System Files".




DataBlade API Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.