Groonga
Loading...
Searching...
No Matches
db.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _grn_db_create_optarg
 

Macros

#define GRN_DB_OPEN_OR_CREATE(ctx, path, optarg, db)
 
#define GRN_DB_EACH_BEGIN_FLAGS(ctx, cursor, id, flags)    GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db((ctx)), cursor, id, flags)
 
#define GRN_DB_EACH_BEGIN_BY_ID(ctx, cursor, id)
 
#define GRN_DB_EACH_BEGIN_BY_KEY(ctx, cursor, id)
 
#define GRN_DB_EACH_END(ctx, cursor)   GRN_TABLE_EACH_END(ctx, cursor)
 

Typedefs

typedef struct _grn_db_create_optarg grn_db_create_optarg
 

Functions

GRN_API grn_objgrn_db_create (grn_ctx *ctx, const char *path, grn_db_create_optarg *optarg)
 Create new database.
 
GRN_API grn_objgrn_db_open (grn_ctx *ctx, const char *path)
 Open the database.
 
GRN_API void grn_db_touch (grn_ctx *ctx, grn_obj *db)
 Update the last modified time of db to the current time. The last modified time is used, for example, to verify whether the cache is valid or not.
 
GRN_API grn_rc grn_db_recover (grn_ctx *ctx, grn_obj *db)
 Check the passed database and recover it if it is broken and it can be recovered.
 
GRN_API grn_rc grn_db_unmap (grn_ctx *ctx, grn_obj *db)
 Unmaps all opened tables and columns in the passed database. Resources used by these opened tables and columns are freed. Normally, this API is needless. Because resources used by opened tables and columns are managed by OS automatically.
 
GRN_API uint32_t grn_db_get_last_modified (grn_ctx *ctx, grn_obj *db)
 
GRN_API bool grn_db_is_dirty (grn_ctx *ctx, grn_obj *db)
 
GRN_API grn_rc grn_db_set_cache (grn_ctx *ctx, grn_obj *db, grn_cache *cache)
 
GRN_API grn_cachegrn_db_get_cache (grn_ctx *ctx, grn_obj *db)
 

Macro Definition Documentation

◆ GRN_DB_EACH_BEGIN_BY_ID

#define GRN_DB_EACH_BEGIN_BY_ID (   ctx,
  cursor,
  id 
)
Value:
cursor, \
id, \
#define GRN_DB_EACH_BEGIN_FLAGS(ctx, cursor, id, flags)
Definition db.h:133
#define GRN_CURSOR_BY_ID
Definition table.h:280
#define GRN_CURSOR_ASCENDING
Definition table.h:273

◆ GRN_DB_EACH_BEGIN_BY_KEY

#define GRN_DB_EACH_BEGIN_BY_KEY (   ctx,
  cursor,
  id 
)
Value:
cursor, \
id, \
#define GRN_CURSOR_BY_KEY
Definition table.h:279

◆ GRN_DB_EACH_BEGIN_FLAGS

#define GRN_DB_EACH_BEGIN_FLAGS (   ctx,
  cursor,
  id,
  flags 
)     GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db((ctx)), cursor, id, flags)

◆ GRN_DB_EACH_END

#define GRN_DB_EACH_END (   ctx,
  cursor 
)    GRN_TABLE_EACH_END(ctx, cursor)

◆ GRN_DB_OPEN_OR_CREATE

#define GRN_DB_OPEN_OR_CREATE (   ctx,
  path,
  optarg,
  db 
)
Value:
(((db) = grn_db_open((ctx), (path))) || \
(db = grn_db_create((ctx), (path), (optarg))))
GRN_API grn_obj * grn_db_open(grn_ctx *ctx, const char *path)
Open the database.
GRN_API grn_obj * grn_db_create(grn_ctx *ctx, const char *path, grn_db_create_optarg *optarg)
Create new database.

Typedef Documentation

◆ grn_db_create_optarg

Function Documentation

◆ grn_db_create()

GRN_API grn_obj * grn_db_create ( grn_ctx ctx,
const char *  path,
grn_db_create_optarg optarg 
)

Create new database.

Parameters
ctxThe context object.
pathFile path of the database. Temporary database if NULL is specified.
optargCurrently, it is not used. It is just ignored.
Returns
The database on success, NULL on error.

◆ grn_db_get_cache()

GRN_API grn_cache * grn_db_get_cache ( grn_ctx ctx,
grn_obj db 
)

◆ grn_db_get_last_modified()

GRN_API uint32_t grn_db_get_last_modified ( grn_ctx ctx,
grn_obj db 
)

◆ grn_db_is_dirty()

GRN_API bool grn_db_is_dirty ( grn_ctx ctx,
grn_obj db 
)

◆ grn_db_open()

GRN_API grn_obj * grn_db_open ( grn_ctx ctx,
const char *  path 
)

Open the database.

Parameters
ctxThe context object.
pathFile path of the database.
Returns
The database on success, NULL on error.

◆ grn_db_recover()

GRN_API grn_rc grn_db_recover ( grn_ctx ctx,
grn_obj db 
)

Check the passed database and recover it if it is broken and it can be recovered.

This API uses lock existence for checking whether the database is broken or not.

Here are recoverable cases:

  • Index column is broken. The index column must have source column.

Here are unrecoverable cases:

  • Object name management feature is broken.
  • Table is broken.
  • Data column is broken.

Object name management feature is used for managing table name, column name and so on. If the feature is broken, the database can't be recovered. Please re-create the database from backup.

Table and data column can be recovered manually by removing an existence lock and re-add data.

Attention
This is a dangerous API. You must not use this API when other thread or process opens the target database. If you use this API against shared database, the database may be broken.
Since
4.0.9
Parameters
ctxThe context object.
dbThe database to be recovered.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.

◆ grn_db_set_cache()

GRN_API grn_rc grn_db_set_cache ( grn_ctx ctx,
grn_obj db,
grn_cache cache 
)

◆ grn_db_touch()

GRN_API void grn_db_touch ( grn_ctx ctx,
grn_obj db 
)

Update the last modified time of db to the current time. The last modified time is used, for example, to verify whether the cache is valid or not.

Parameters
ctxThe context object.
dbThe database.

◆ grn_db_unmap()

GRN_API grn_rc grn_db_unmap ( grn_ctx ctx,
grn_obj db 
)

Unmaps all opened tables and columns in the passed database. Resources used by these opened tables and columns are freed. Normally, this API is needless. Because resources used by opened tables and columns are managed by OS automatically.

Attention
This is a thread unsafe API. You can't touch the database while this API is running.
Since
5.0.7
Parameters
ctxThe context object.
dbThe database to be unmaped.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.