URL: http://www.firstbasesoftware.com/man/man3/useidx.htm
Last modified: 4 April 1996
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]


NAME

useidx, addidx, subidx - manipulate autoindexes within a database

SYNOPSIS

#include <firstbase/fb.h>

fb_useidx(i, db)
int i;
fb_database *db;

fb_addidx(iname, db)
char *iname;
fb_database *db;

fb_subidx(iname, db)
char *iname;
fb_database *db;

DESCRIPTION

As explained in the database(4) manual page, a database structure contains all of the elements needed for an entire database, including an array of automatic Btree+ indexes, as defined by autoindex(5). The routines described here manipulate the b_autoindex array inside database db at runtime.

The best method for using multiple indexes is via the autoindex(5) file. Using this method, a group of indexes can be used and kept current. After opening a database, each of the autoindexes is stored as an entry in the b_autoindex array. For example, the following code prints each autoindex name:


fb_database *db; int i; db = fb_dballoc(); fb_dbargs("test", NIL, db); fb_opendb(db, READWRITE, FB_ALLINDEX, FB_OPTIONAL_INDEX); for (i = 0; i < db->b_maxauto; i++) printf("%s", db->b_autoindex[i]->autoname);

The idea is to open the database without a current index, but with all of its autoindexes. Then, as each autoindex is needed, it can be made the current index using fb_useidx, which will initialize pointers inside db, enabling getxrec(3) calls to search different indexes.

The argument i is the subscript into the autoindex array, from 0 to db->b_maxauto - 1. The integer variable db->b_maxauto stores the total number of automatic indexes. The return status is either FB_AOK or FB_ERROR.

Additional autoindexes can be added at run time using fb_addidx. The parameter iname is the name of the index. Indexes can also be removed from the array of autoindexes using fb_subidx.

CLIENT/SERVER

Each of these routines will transparently call the RPC mechanism of the similar name when the global FirstBase variable cdb_use_rpc is set to one. See fb_clnt_create(3) for more details.

SEE ALSO

database(4), index(4), btree(4), dballoc(3), dbargs(3), opendb(3), openidx(3), autoindex(5).


URL: http://www.firstbasesoftware.com/man/man3/useidx.htm
Last modified: 4 April 1996
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]