Symisc UnQLite

An Embeddable NoSQL Database Engine



UnQLite C/C++ API Reference - Database Engine Handle.

Syntax

int unqlite_config(unqlite *pDb,int nOp,...);


Configure a database handle.


Description


This routine is used to configure a database handle obtained by a prior successful call to unqlite_open().

The second argument to unqlite_config() is an integer configuration option that determines what property of the database is to be configured. Subsequent arguments vary depending on the configuration option in the second argument. The default configuration is recommended for most applications and so this routine is usually not necessary. It is provided to support rare applications with unusual needs. Here is a list of allowed configuration options


Commands
Expected Arguments
Description
UNQLITE_CONFIG_JX9_ERR_LOG
Two Arguments:

const char **pzPtr,

int *pLen;

When something goes wrong during compilation of the target Jx9 script due to an erroneous Jx9 code, the compiler error log is redirected to an internal buffer. This option can be used to point to that buffer. The first argument is a pointer address to a const char *.

The second argument is an optional pointer to an integer. When set (i.e. not null), the integer value will hold the length of the error log in bytes.

Example:

const char *zErrLog;

int nLen;

/* Extract the compiler error log */

unqlite_config(

   pDb,

   UNQLITE_CONFIG_JX9_ERR_LOG,

   &zErrLog, /* First arg */

   &nLen     /* Second arg */

);

if( nLen > 0 ){

   puts(zErrLog); /* Output*/

}
UNQLITE_CONFIG_MAX_PAGE_CACHE One Argument:

int nMaxPage;


Maximum raw pages to cache in memory. This is a simple hint, UnQLite is not forced to honor it.

UNQLITE_CONFIG_ERR_LOG Two Arguments:

const char **pzPtr,

int *pLen;

The database error log is stored in an internal buffer. When something goes wrong during a commit, rollback, store, append operation, a human-readable error message is generated to help clients diagnostic the problem. This option can be used to point to that buffer.

The first argument is a pointer address to a const char *.

The second argument is an optional pointer to an integer. When set (i.e. not null), the integer value will hold the length of the error log in bytes.

Example:

if( rc != UNQLITE_OK ){

  const char *zBuf;

  int iLen;

  /* Something goes wrong, extract database error log */

 unqlite_config(

  pDb,

  UNQLITE_CONFIG_ERR_LOG,

  &zBuf,

  &iLen

);

  if( iLen > 0 ){

    puts(zBuf);

  }

}

UNQLITE_CONFIG_KV_ENGINE One Argument:

const char *zKvName

Switch to another Key/Value storage engine. This option is reserved for future usage.

UNQLITE_CONFIG_DISABE_AUTO_COMMIT No Arguments

Normally, If unqlite_close() is invoked while a transaction is open, the transaction is automatically committed. But, if this option is set, then the transaction is automatically rolled back and you should call unqlite_commit() manually to commit all database changes.

UNQLITE_CONFIG_GET_KV_NAME One Argument:

const char **pzName;

Extract the name of the underlying Key/Value storage engine (i.e. Hash, Mem, R+Tree, LSM, etc.).


Parameters


pDb

A pointer to a unQLite Database Handle.

nOp

An integer configuration option that determines what property of the database is to be configured.


Return value


UNQLITE_OK is returned on success. Any other return value typically UNQLITE_UNKNOWN (Unknown configuration verb) indicates failure.


See also


unqlite_open, unqlite_close, unqlite_kv_store, unqlite_kv_append, unqlite_compile, unqlite_vm_exec, unqlite_commit, unqlite_rollback.



Symisc Systems
Copyright © Symisc Systems