Effect of altering dbspaces on access modes

When you alter a dbspace from read-write to read-only mode, or vice versa, the operating system level access mode changes.

ALTER DBSPACE READWRITE | READONLY involves a transition period during which the dbspace is closed and reopened. By the time the ALTER statement commits, the dbspace is open in the new access mode. The exception is when the sole remaining read-write dbspace is altered read-only. In that case, some database structures must be written during the checkpoint command that follows the ALTER statement.

Recovery of ALTER DBSPACE replays the statement if the server fails before completing the checkpoint after the ALTER. In that case, the dbspace first opens in the “before” mode during database open. The recovery replay alters the dbspace to the “after” mode.

The read-write status of a dbspace is stored in the dbspace file header. Dbspaces in relocate mode open with read-write access at the operating system level. Since the file header contains the dbspace mode, Sybase IQ rewrites the file header to alter the dbspace from relocate to read-only mode. Keeping the dbspace open in read-write mode while it is in relocate mode facilitates this transition.

Sybase IQ allows the last dbspace of the main store to be altered read-only. All of the dbspaces of the main store may be made read-only. See “Using read-only hardware”.

In each store, one dbspace contains special structures owned by the database. For the IQ Main and IQ Local Stores, these structures are the freelist root page, the two database identity blocks, and the multiplex cm block (which exists in non-multiplex databases as well). In the IQ Temp Store, the special dbspace contains the temporary freelist root page.

The special structures are normally on a read-write dbspace. If the dbspace containing the special structures is altered read-only, the structures will move to another read-write dbspace. If the sole read-write dbspace is altered read-only, these structures remain on that dbspace while it is in read-only mode and while there are no other read-write dbspaces. The special structures will never be located on a dbspace in relocate mode.