FLAIM: Database Maintenance Functions

- Main Page
- Modules
- Classes
- Files

# Database Maintenance Functions
[Database Functions]

## Functions
FLMEXP RCODE FLMAPI | FlmDbCheck (HFDB hDb, const char *pszDbFileName, const char *pszDataDir, const char *pszRflDir, FLMUINT uiCheckFlags, F_Pool *pPool, DB_CHECK_PROGRESS *pDbStats, STATUS_HOOK fnStatusHook, void *pvAppArg)
| Check a database for corruptions.
FLMEXP RCODE FLMAPI | FlmDbRebuild (const char *pszSourceDbPath, const char *pszSourceDataDir, const char *pszDestDbPath, const char *pszDestDataDir, const char *pszDestRflDir, const char *pszDictPath, CREATE_OPTS *pCreateOpts, FLMUINT *puiTotalRecords, FLMUINT *puiRecsRecovered, STATUS_HOOK fnStatusHook, void *pvAppData)
| Rebuild a database.
FLMEXP RCODE FLMAPI | FlmDbReduceSize (HFDB hDb, FLMUINT uiCount, FLMUINT *puiCount)
| Reduce the database size - returning unused blocks back to the file system.
FLMEXP RCODE FLMAPI | FlmDbSweep (HFDB hDb, FLMUINT uiSweepMode, FLMUINT uiCallbackFlags, STATUS_HOOK fnStatusHook, void *pvAppData)
| Traverse records in the database looking for unused fields.
FLMEXP RCODE FLMAPI | FlmDbUpgrade (HFDB hDb, FLMUINT uiNewVersion, STATUS_HOOK fnStatusCallback, void *pvAppData)
| Upgrade a database.
FLMEXP RCODE FLMAPI | FlmMaintenanceStatus (HFDB hDb, FMAINT_STATUS *pMaintStatus)
| Get the current status of the background maintenance thread for a database.

## Function Documentation

FLMEXP RCODE FLMAPI FlmDbCheck | ( | HFDB | hDb,
|  | const char * | pszDbFileName,
|  | const char * | pszDataDir,
|  | const char * | pszRflDir,
|  | FLMUINT | uiCheckFlags,
|  | F_Pool * | pPool,
|  | DB_CHECK_PROGRESS * | pDbStats,
|  | STATUS_HOOK | fnStatusHook,
|  | void * | pvAppArg
| ) |

  | Check a database for corruptions. Parameters:
  hDb | Database handle of database to be checked. If HFDB_NULL, FlmDbCheck will call FlmDbOpen() using the pszDbFileName, pszDataDir, pszRflDir, and uiFlags parameters.
  pszDbFileName | Name of database to be checked. This is only used if hDb is HFDB_NULL.
  pszDataDir | Directory where database's data files are located. This is only used if hDb is HFDB_NULL. If this parameter is NULL, data files are assumed to be in the same directory as pszDbFileName.
  pszRflDir | Directory where database's RFL files are located. This is only used if hDb is HFDB_NULL. If this parameter is NULL, RFL files are assumed to be in the same directory as pszDbFileName.
  uiCheckFlags | Checking options. May include one or more of the following flags ORed together: FLM_CHK_INDEX_REFERENCING - Check logical integrity of indexes to make sure all keys in the index are in the referenced records and that all keys generated from records are in the index FLM_CHK_FIELDS - Check fields in records
  pPool | Memory pool for allocating memory to hold various statistics in the pDbStats parameter.
  pDbStats | Statistics collected about the database during the check.
  fnStatusHook | Callback status function.
  pvAppArg | Pointer to application data. This pointer is passed into fnStatusHook whenever it is called.

FLMEXP RCODE FLMAPI FlmDbRebuild | ( | const char * | pszSourceDbPath,
|  | const char * | pszSourceDataDir,
|  | const char * | pszDestDbPath,
|  | const char * | pszDestDataDir,
|  | const char * | pszDestRflDir,
|  | const char * | pszDictPath,
|  | CREATE_OPTS * | pCreateOpts,
|  | FLMUINT * | puiTotalRecords,
|  | FLMUINT * | puiRecsRecovered,
|  | STATUS_HOOK | fnStatusHook,
|  | void * | pvAppData
| ) |

  | Rebuild a database. This function creates a new database from an existing database by extracting records from the existing database and inserting them into the new database. Any corrupted parts of the existing database are ignored. In this way, if a database is corrupt, a new database may be built from it that has no corruptions. In addition, indexes in the new database will be rebuilt. Parameters:
  pszSourceDbPath | Name of database to be rebuilt.
  pszSourceDataDir | Directory where database's data files are located. If NULL, it is assumed that the database's data files are located in the same directory as pszSourceDbPath.
  pszDestDbPath | Name of new database that is to be created.
  pszDestDataDir | Directory where new database's data files are to be created. If NULL, data files will be created in the same directory as pszDestDbPath.
  pszDestRflDir | Directory where new database's RFL files are to be created. If NULL, RFL files will be created in the same directory as pszDestDbPath.
  pszDictPath | If non-NULL, this is the name of a file that has dictionary definitions which are to be loaded into the new database's dictionary container.
  pCreateOpts | Create options for the new database.
  puiTotalRecords | Returns the total number of records that were found in the source database.
  puiRecsRecovered | Returns the total number of records that were recovered from the source database.
  fnStatusHook | Callback function. FlmDbRebuild() calls this function to report rebuild progress.
  pvAppData | Pointer to application data which will be passed into the callback function whenever it is called.

FLMEXP RCODE FLMAPI FlmDbReduceSize | ( | HFDB | hDb,
|  | FLMUINT | uiCount,
|  | FLMUINT * | puiCount
| ) |

  | Reduce the database size - returning unused blocks back to the file system. Parameters:
  hDb | Database handle.
  uiCount | Maximum number of unused blocks to be returned to file system.
  puiCount | Number of blocks actually returned. This should be the same as the number of blocks requested, unless there are not that many unused blocks.

FLMEXP RCODE FLMAPI FlmDbSweep | ( | HFDB | hDb,
|  | FLMUINT | uiSweepMode,
|  | FLMUINT | uiCallbackFlags,
|  | STATUS_HOOK | fnStatusHook,
|  | void * | pvAppData
| ) |

  | Traverse records in the database looking for unused fields. Parameters:
  hDb | Database handle.
  uiSweepMode | Flags indicating what actions FlmDbSweep() should do while it is traversing the database. It may be any of the following flags ORed together: SWEEP_CHECKING_FLDS - Look for field definitions marked as "checking". These fields should be checked to see if they are still in use SWEEP_PURGED_FLDS - Look for field definitions marke as "purged". These fields should be removed from records SWEEP_STATS - Only calls the callback function. This provides a way for an application to collect database statistics
  uiCallbackFlags | Flags indicating what what events FlmDbSweep() should report through the callback function. It may be any of the following flags ORed together: EACH_CONTAINER - Callback function is called whenever FlmDbSweep() begins traversing a new container EACH_RECORD - Callback function is called for each record traversed EACH_FIELD - Callback function is called for each field traversed EACH_CHANGE - Callback function is called whenever a field that was marked as "checking" is found in the database and the state is changed back to "unused". It is also calld whenever a field that was marked as "purged" is removed from a record
  fnStatusHook | Callback function. See eStatusType::FLM_SWEEP_STATUS for documentation on data that is passed to the callback function when it is called.
  pvAppData | Pointer to application data that will be passed to the callback function whenever it is called.

FLMEXP RCODE FLMAPI FlmDbUpgrade | ( | HFDB | hDb,
|  | FLMUINT | uiNewVersion,
|  | STATUS_HOOK | fnStatusCallback,
|  | void * | pvAppData
| ) |

  | Upgrade a database. Parameters:
  hDb | Database handle.
  uiNewVersion | Version database is to be upgraded to. This must be greater than the current version of the database.
  fnStatusCallback | Callback function that is called while the database is being upgraded. See documentaiton eStatusType::FLM_DB_UPGRADE_STATUS for documentation on data that is passed to the callback function when it is called.
  pvAppData | Pointer to application data that will be passed to the callback function whenever it is called.

FLMEXP RCODE FLMAPI FlmMaintenanceStatus | ( | HFDB | hDb,
|  | FMAINT_STATUS * | pMaintStatus
| ) |

  | Get the current status of the background maintenance thread for a database. Parameters:
  hDb | Database handle.
  pMaintStatus | Status is returned in this structure.