Next: , Previous: , Up: Top   [Contents][Index]


12 Changing database format

As of version 1.23, GDBM supports databases in two formats: standard and extended. The standard format is used most often. The extended database format is used to provide additional crash resistance (see Crash Tolerance).

Depending on the value of the flags parameter in a call to gdbm_open (see GDBM_NUMSYNC), a database can be created in either format.

The format of an existing database can be changed using the gdbm_convert function:

gdbm interface: int gdbm_convert (GDBM_FILE dbf, int flag)

Changes the format of the database file dbf. Allowed values for flag are:

0

Convert database to the standard format.

GDBM_NUMSYNC

Convert database to the extended numsync format (see Numsync).

On success, the function returns 0. In this case, it should be followed by a call to gdbm_sync (see Sync) or gdbm_close (see Close) to ensure the changes are written to the disk.

On error, returns -1 and sets the gdbm_errno variable (see gdbm_errno).

If the database is already in the requested format, the function returns success (0) without doing anything.