All data operations are performed in the context of a WT_SESSION. More...
Public Member Functions | |
int | close (WT_SESSION *session, const char *config) |
Close the session handle. More... | |
int | reconfigure (WT_SESSION *session, const char *config) |
Reconfigure a session handle. More... | |
Cursor handles | |
int | open_cursor (WT_SESSION *session, const char *uri, WT_CURSOR *to_dup, const char *config, WT_CURSOR **cursorp) |
Open a new cursor on a data source or duplicate an existing cursor. More... | |
Table operations | |
int | create (WT_SESSION *session, const char *name, const char *config) |
Create a table, column group, index or file. More... | |
int | compact (WT_SESSION *session, const char *name, const char *config) |
Compact a live row- or column-store btree (log-structured merge trees cannot be compacted). More... | |
int | drop (WT_SESSION *session, const char *name, const char *config) |
Drop (delete) an object. More... | |
int | log_printf (WT_SESSION *session, const char *fmt,...) |
Print something to the log file. More... | |
int | rename (WT_SESSION *session, const char *uri, const char *newuri, const char *config) |
Rename an object. More... | |
int | salvage (WT_SESSION *session, const char *name, const char *config) |
Salvage a file or table. More... | |
int | truncate (WT_SESSION *session, const char *name, WT_CURSOR *start, WT_CURSOR *stop, const char *config) |
Truncate a file, table or cursor range. More... | |
int | upgrade (WT_SESSION *session, const char *name, const char *config) |
Upgrade a file or table. More... | |
int | verify (WT_SESSION *session, const char *name, const char *config) |
Verify a file or table. More... | |
Transactions | |
int | begin_transaction (WT_SESSION *session, const char *config) |
Start a transaction in this session. More... | |
int | commit_transaction (WT_SESSION *session, const char *config) |
Commit the current transaction. More... | |
int | rollback_transaction (WT_SESSION *session, const char *config) |
Roll back the current transaction. More... | |
int | checkpoint (WT_SESSION *session, const char *config) |
Write a transactionally consistent snapshot of a database or set of objects. More... | |
Public Attributes | |
WT_CONNECTION * | connection |
The connection for this session. More... | |
All data operations are performed in the context of a WT_SESSION.
This encapsulates the thread and transactional context of the operation.
Thread safety: A WT_SESSION handle is not usually shared between threads, see Multithreading for more information.
int WT_SESSION::begin_transaction | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Start a transaction in this session.
The transaction remains active until ended by WT_SESSION::commit_transaction or WT_SESSION::rollback_transaction. Operations performed on cursors capable of supporting transactional operations that are already open in this session, or which are opened before the transaction ends, will operate in the context of the transaction.
All open cursors are reset.
WT_SESSION::begin_transaction will fail if a transaction is already in progress in the session.
session | the session handle | ||||||||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::checkpoint | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Write a transactionally consistent snapshot of a database or set of objects.
The checkpoint includes all transactions committed before the checkpoint starts. Additionally, checkpoints may optionally be discarded.
session | the session handle | |||||||||||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::close | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Close the session handle.
This will release the resources associated with the session handle, including rolling back any active transactions and closing any cursors that remain open in the session.
session | the session handle |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::commit_transaction | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Commit the current transaction.
A transaction must be in progress when this method is called.
All open cursors are reset.
If WT_SESSION::commit_transaction returns an error, the transaction was rolled-back, not committed.
session | the session handle |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::compact | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Compact a live row- or column-store btree (log-structured merge trees cannot be compacted).
session | the session handle | ||||||
name | the URI of the object to compact, such as "table:stock" | ||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::create | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Create a table, column group, index or file.
session | the session handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name | the URI of the object to create, such as "table:stock" . For a description of URI formats see Data Sources. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::drop | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Drop (delete) an object.
session | the session handle | |||||||||
name | the URI of the object to drop, such as "table:stock" | |||||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::log_printf | ( | WT_SESSION * | session, |
const char * | fmt, | ||
... | |||
) |
Print something to the log file.
The database must be configured for logging when this method is called.
session | the session handle |
fmt | a printf format specifier |
int WT_SESSION::open_cursor | ( | WT_SESSION * | session, |
const char * | uri, | ||
WT_CURSOR * | to_dup, | ||
const char * | config, | ||
WT_CURSOR ** | cursorp | ||
) |
Open a new cursor on a data source or duplicate an existing cursor.
An existing cursor can be duplicated by passing it as the to_dup
parameter and setting the uri
parameter to NULL:
Cursors being duplicated must have a key set, and successfully duplicated cursors are positioned at the same place in the data source as the original.
To reconfigure a cursor, duplicate it with a new configuration value:
Cursor handles should be discarded by calling WT_CURSOR::close.
Cursors capable of supporting transactional operations operate in the context of the current transaction, if any. Ending a transaction implicitly resets all open cursors.
Cursors are relatively light-weight objects but may hold references to heavier-weight objects; applications should re-use cursors when possible, but instantiating new cursors is not so expensive that applications need to cache cursors at all cost.
session | the session handle | |||||||||||||||||||||||||||||||
uri | the data source on which the cursor operates; cursors are usually opened on tables, however, cursors can be opened on any data source, regardless of whether it is ultimately stored in a table. Some cursor types may have limited functionality (for example, they may be read-only or not support transactional updates). See Data Sources for more information. The following are the builtin cursor types:
| |||||||||||||||||||||||||||||||
to_dup | a cursor to duplicate | |||||||||||||||||||||||||||||||
config | Configuration string, see Configuration Strings. Permitted values:
| |||||||||||||||||||||||||||||||
[out] | cursorp | a pointer to the newly opened cursor |
int WT_SESSION::reconfigure | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Reconfigure a session handle.
WT_SESSION::reconfigure will fail if a transaction is in progress in the session. All open cursors are reset.
session | the session handle | ||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::rename | ( | WT_SESSION * | session, |
const char * | uri, | ||
const char * | newuri, | ||
const char * | config | ||
) |
Rename an object.
session | the session handle |
uri | the current URI of the object, such as "table:old" |
newuri | the new URI of the object, such as "table:new" |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::rollback_transaction | ( | WT_SESSION * | session, |
const char * | config | ||
) |
Roll back the current transaction.
A transaction must be in progress when this method is called.
All open cursors are reset.
session | the session handle |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::salvage | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Salvage a file or table.
Salvage rebuilds the file, or files of which a table is comprised, discarding any corrupted file blocks.
Previously deleted records may re-appear, and inserted records may disappear, when salvage is done, so salvage should not be run unless it is known to be necessary. Normally, salvage should be called after a file or table has been corrupted, as reported by the WT_SESSION::verify method.
Files are rebuilt in place, the salvage method overwrites the existing files.
session | the session handle | ||||||
name | the URI of the file or table to salvage | ||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
int WT_SESSION::truncate | ( | WT_SESSION * | session, |
const char * | name, | ||
WT_CURSOR * | start, | ||
WT_CURSOR * | stop, | ||
const char * | config | ||
) |
Truncate a file, table or cursor range.
Truncate a file or table.
Truncate a cursor range. When truncating based on a cursor position, it is not required the cursor reference a record in the object, only that the key be set. This allows applications to discard portions of the object name space without knowing exactly what records the object contains.
session | the session handle |
name | the URI of the file or table to truncate |
start | optional cursor marking the first record discarded; if NULL , the truncate starts from the beginning of the object |
stop | optional cursor marking the last record discarded; if NULL , the truncate continues to the end of the object |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::upgrade | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Upgrade a file or table.
Upgrade upgrades a file or table, if upgrade is required.
session | the session handle |
name | the URI of the file or table to upgrade |
config | Configuration string, see Configuration Strings. No values currently permitted. |
int WT_SESSION::verify | ( | WT_SESSION * | session, |
const char * | name, | ||
const char * | config | ||
) |
Verify a file or table.
Verify reports if a file, or the files of which a table is comprised, have been corrupted. The WT_SESSION::salvage method can be used to repair a corrupted file,
session | the session handle | ||||||||||||
name | the URI of the file or table to verify | ||||||||||||
config | Configuration string, see Configuration Strings. Permitted values:
|
WT_CONNECTION* WT_SESSION::connection |
The connection for this session.