Access the default open flag

When you open a smart large object, you can specify the open mode for the data. The open mode describes the context in which the I/O operations on the smart large object are performed. The LO-specification structure uses a bitmask flag, called a default-open-mode flag, to specify the default open mode of a smart large object.

The following tables show the open-mode constants of an LO-specification structure.
Table 1. Access open-mode constants in the LO-specification structure
Open-mode constant Description
MI_LO_RDONLY Read-only mode
MI_LO_DIRTY_READ Dirty-read mode
MI_LO_WRONLY Write-only mode
MI_LO_APPEND Write/append mode
MI_LO_RDWR Read/write mode
MI_LO_TRUNC Truncate

These access-mode flags for a smart large object are patterned after the UNIX™ System V file-access modes. For more information, see Access modes.

Table 2. Access-method open-mode constants in the LO-specification structure
Open-mode constant Description
MI_LO_RANDOM Random access
MI_LO_SEQUENTIAL Sequential access
MI_LO_FORWARD Forward
MI_LO_REVERSE Reverse

For more information, see Access methods.

Table 3. Buffering open-mode constants in the LO-specification structure
Open-mode constant Description
MI_LO_BUFFER Buffered access (Buffered I/O)
MI_LO_NOBUFFER Unbuffered access (Lightweight I/O)

For more information, see Buffering modes.

Table 4. Locking open-mode constants in the LO-specification structure
Open-mode constant Description
MI_LO_LOCKALL Lock-all locks
MI_LO_LOCKRANGE Byte-range locks

For more information, see Locking modes.

The milo.h header file defines the open-mode constants: MI_LO_RDONLY, MI_LO_DIRTY_READ, MI_LO_WRONLY, MI_LO_APPEND, MI_LO_RDWR, MI_LO_TRUNC, MI_LO_RANDOM, MI_LO_SEQUENTIAL, MI_LO_FORWARD, MI_LO_REVERSE, MI_LO_BUFFER, MI_LO_NOBUFFER, MI_LO_LOCKALL, and MI_LO_LOCKRANGE.

The following table shows the LO-specification accessor functions for the default-open-mode information.
Table 5. Accessor functions for attribute information in the LO-specification structure
LO-specification accessor function Description
mi_lo_specget_def_open_flags() Overrides the system default open mode with the open mode that the default-open-mode flag specifies
mi_lo_specset_def_open_flags() Retrieves the default-open-mode flag from the LO-specification structure
To set a default-open-mode flag:
  1. Use the appropriate open-mode constants. If you need to set more than one default-open-mode value, use the C-language bitwise OR operator (|) to mask open-mode constants together.
  2. Use the mi_lo_specset_def_open_flags() accessor function to store the default-open-mode flag in the LO-specification structure.
Masking mutually exclusive flags results in an error. However, you can mask the MI_LO_APPEND constant with another access-mode constant. In any of these OR combinations, the seek operation remains unaffected. The following table shows the effect that each of the OR combinations has on the read and write operations.
OR operation Read operations Write operations
MI_LO_RDONLY | MI_LO_APPEND Starts at the LO seek position and then moves the seek position to the end of the data that has been read Fails and does not move the LO seek position
MI_LO_WRONLY | MI_LO_APPEND Fails and does not move the LO seek position Moves the LO seek position to the end of the smart large object and then writes the data

The LO seek position is at the end of the data after the write operation.

MI_LO_RDWR | MI_LO_APPEND Starts at the LO seek position and then moves the seek position to the end of the data that has been read Moves the LO seek position to the end of the smart large object and then writes the data

The LO seek position is at the end of the data after the write operation.

If you do not specify a value for a particular part of the open mode, the database server assumes the following system default open mode when you open a smart large object.
Access capability Default open mode Smart-large-object constant
Access mode Read-only MI_LO_RDONLY
Access method Random MI_LO_RANDOM
Buffering Buffered access MI_LO_BUFFER
Locking Whole-object locks MI_LO_LOCKALL

You can specify a different open mode for a particular smart large object when you open a smart large object. For more information about how to open a smart large object, see Open a smart large object.