#include <database.h>
Public Types | |
typedef void(* | dbErrorHandler )(dbErrorClass error, char const *msg, int msgarg) |
enum | DetachFlags { COMMIT = 1, DESTROY_CONTEXT = 2 } |
enum | dbErrorClass { NoError, QueryError, ArithmeticError, IndexOutOfRangeError, DatabaseOpenError, FileError, OutOfMemoryError, Deadlock, NullReferenceError, LockRevoked, FileLimitExeeded } |
enum | dbAccessType { dbReadOnly = 0, dbAllAccess = 1, dbConcurrentRead = 2, dbConcurrentUpdate = 3 } |
Public Methods | |
bool | open (char const *databaseName, char const *fileName=NULL, time_t waitLockTimeoutMsec=INFINITE, time_t commitDelaySec=0) |
void | close () |
void | commit () |
void | precommit () |
void | rollback () |
void | scheduleBackup (char const *fileName, time_t periodSec) |
void | attach () |
void | detach (int flags=COMMIT|DESTROY_CONTEXT) |
void | lock () |
bool | backup (char const *file, bool compactify) |
void | assign (dbTableDescriptor &desc) |
void | setConcurrency (unsigned nThreads) |
long | getAllocatedSize () |
long | getDatabaseSize () |
dbErrorHandler | setErrorHandler (dbErrorHandler newHandler) |
virtual void | handleError (dbErrorClass error, char const *msg=NULL, int arg=0) |
void | insertRecord (dbTableDescriptor *table, dbAnyReference *ref, void const *record) |
bool | isOpen () const |
int | getVersion () |
void | setFileSizeLimit (size_t limit) |
template<class T> dbReference< T > | insert (T const &record) |
dbTableDescriptor * | lookupTable (dbTableDescriptor *desc) |
dbDatabase (dbAccessType type=dbAllAccess, size_t dbInitSize=dbDefaultInitDatabaseSize, size_t dbExtensionQuantum=dbDefaultExtensionQuantum, size_t dbInitIndexSize=dbDefaultInitIndexSize, int nThreads=1) | |
virtual | ~dbDatabase () |
Static Public Methods | |
void | cleanup () |
Public Attributes | |
const dbAccessType | accessType |
const size_t | initSize |
const size_t | extensionQuantum |
const size_t | initIndexSize |
Static Public Attributes | |
unsigned | dbParallelScanThreshold |
Protected Types | |
enum | dbLockType { dbSharedLock, dbExclusiveLock, dbCommitLock } |
Protected Methods | |
void | delayedCommit () |
void | backupScheduler () |
void | commit (dbDatabaseThreadContext *ctx) |
void | restoreTablesConsistency () |
dbRecord * | getRow (oid_t oid) |
dbRecord * | putRow (oid_t oid, size_t newSize) |
dbRecord * | putRow (oid_t oid) |
byte * | get (oid_t oid) |
byte * | put (oid_t oid) |
bool | isIndexApplicable (dbAnyCursor *cursor, dbExprNode *expr, dbExprNode *andExpr, dbFieldDescriptor *&indexedField) |
bool | isIndexApplicable (dbAnyCursor *cursor, dbExprNode *expr, dbExprNode *andExpr) |
bool | followInverseReference (dbExprNode *expr, dbExprNode *andExpr, dbAnyCursor *cursor, oid_t iref) |
bool | existsInverseReference (dbExprNode *expr, int nExistsClauses) |
bool | evaluate (dbExprNode *expr, oid_t oid, dbTable *table, dbAnyCursor *cursor) |
void | select (dbAnyCursor *cursor) |
void | select (dbAnyCursor *cursor, dbQuery &query) |
void | traverse (dbAnyCursor *cursor, dbQuery &query) |
void | update (oid_t oid, dbTableDescriptor *table, void const *record) |
void | remove (dbTableDescriptor *table, oid_t oid) |
offs_t | allocate (size_t size, oid_t oid=0) |
void | deallocate (offs_t pos, size_t size) |
void | extend (offs_t size) |
void | cloneBitmap (offs_t pos, size_t size) |
oid_t | allocateId (int n=1) |
void | freeId (oid_t oid, int n=1) |
void | updateCursors (oid_t oid) |
void | recovery () |
bool | checkVersion () |
oid_t | allocateObject (dbInternalObject marker) |
oid_t | allocateRow (oid_t tableId, size_t size) |
void | freeRow (oid_t tableId, oid_t oid) |
void | freeObject (oid_t oid) |
bool | beginTransaction (dbLockType) |
void | endTransaction () |
void | endTransaction (dbDatabaseThreadContext *ctx) |
void | initializeMetaTable () |
bool | loadScheme (bool alter) |
bool | completeDescriptorsInitialization () |
void | reformatTable (oid_t tableId, dbTableDescriptor *desc) |
bool | addIndices (bool alter, dbTableDescriptor *desc) |
oid_t | addNewTable (dbTableDescriptor *desc) |
void | updateTableDescriptor (dbTableDescriptor *desc, oid_t tableId) |
void | insertInverseReference (dbFieldDescriptor *fd, oid_t reverseId, oid_t targetId) |
void | removeInverseReferences (dbTableDescriptor *desc, oid_t oid) |
void | removeInverseReference (dbFieldDescriptor *fd, oid_t reverseId, oid_t targetId) |
void | deleteTable (dbTableDescriptor *desc) |
void | dropTable (dbTableDescriptor *desc) |
void | createIndex (dbFieldDescriptor *fd) |
void | createHashTable (dbFieldDescriptor *fd) |
void | dropIndex (dbFieldDescriptor *fd) |
void | dropHashTable (dbFieldDescriptor *fd) |
void | linkTable (dbTableDescriptor *table, oid_t tableId) |
void | unlinkTable (dbTableDescriptor *table) |
bool | wasReserved (offs_t pos, size_t size) |
void | reserveLocation (dbLocation &location, offs_t pos, size_t size) |
void | commitLocation () |
dbTableDescriptor * | findTable (char const *name) |
dbTableDescriptor * | findTableByName (char const *name) |
Static Protected Methods | |
void thread_proc | delayedCommitProc (void *arg) |
void thread_proc | backupSchedulerProc (void *arg) |
void _fastcall | execute (dbExprNode *expr, dbInheritedAttribute &iattr, dbSynthesizedAttribute &sattr) |
void | deleteCompiledQuery (dbExprNode *tree) |
Protected Attributes | |
dbThreadPool | threadPool |
dbThreadContext< dbDatabaseThreadContext > | threadContext |
byte * | baseAddr |
dbHeader * | header |
offs_t * | currIndex |
offs_t * | index [2] |
unsigned | parThreads |
bool | modified |
size_t | currRBitmapPage |
size_t | currRBitmapOffs |
size_t | currPBitmapPage |
size_t | currPBitmapOffs |
dbLocation * | reservedChain |
char * | databaseName |
int | databaseNameLen |
char * | fileName |
int | version |
size_t | mmapSize |
size_t | committedIndexSize |
size_t | currIndexSize |
oid_t | updatedRecordId |
unsigned | dbWaitLockTimeout |
size_t | dbFileSizeLimit |
bool | uncommittedChanges |
dbFile | file |
dbSharedObject< dbMonitor > | shm |
dbGlobalCriticalSection | cs |
dbGlobalCriticalSection | mutatorCS |
dbInitializationMutex | initMutex |
dbSemaphore | writeSem |
dbSemaphore | readSem |
dbSemaphore | upgradeSem |
dbEvent | backupCompletedEvent |
dbMonitor * | monitor |
dbTableDescriptor * | tables |
int * | bitmapPageAvailableSpace |
bool | opened |
long | allocatedSize |
time_t | commitDelay |
time_t | commitTimeout |
time_t | commitTimerStarted |
dbMutex | delayedCommitStartTimerMutex |
dbMutex | delayedCommitStopTimerMutex |
dbLocalEvent | delayedCommitStartTimerEvent |
dbEvent | delayedCommitStopTimerEvent |
dbLocalEvent | commitThreadSyncEvent |
dbMutex | backupMutex |
dbLocalEvent | backupInitEvent |
char * | backupFileName |
time_t | backupPeriod |
bool | stopDelayedCommitThread |
dbThread | backupThread |
dbThread | commitThread |
int | accessCount |
dbL2List | threadContextList |
dbMutex | threadContextListMutex |
dbErrorHandler | errorHandler |
Static Protected Attributes | |
size_t | internalObjectSize [] |
Friends | |
class | dbSelection |
class | dbAnyCursor |
class | dbHashTable |
class | dbQuery |
class | dbTtree |
class | dbTtreeNode |
class | dbParallelQueryContext |
class | dbServer |
class | dbColumnBinding |
class | dbUserFunctionArgument |
class | dbAnyContainer |
class | dbCLI |
class | GiSTdb |
|
Start database transaction
|
|
Database constructor
|
|
Database detructor |
|
Add new indices to the table.
|
|
Add new table to the database
|
|
Allocate object in the database e@param size size of alocated object
|
|
Allocate object identifier(s)
|
|
Allocate internal object
|
|
Allocate row in the table
|
|
Assign table to the database
|
|
Attach current thread to the database. This method should be executed for all threads except one which opened the database. |
|
Perform backup to the specified file
|
|
Check if program works with correct version of memory mapped object (if memory mapped object is reallocated by some client, its version number is incremented, so all other client will be able to notice it and also reallocate their memory mapping objects.
|
|
Cleanup all objects with program life cycle created by FastDB should be registred as atexit handler or ivoked before program termination. The promary idea of this method is to make memory leacks detector programs happy. |
|
Clone memory allocation bitmap for region [pos, pos+size)
|
|
Close database |
|
Commit transaction
|
|
Commit transaction |
|
Remove location from list of reserved locations. It is done after location is marked as occupied in bitmap. |
|
This method is invoked by SubSQL to complete table descriptors initialization after loading of all table descriptoes from thr database
|
|
Create hash table for the field
|
|
Create T-Tree index for the field
|
|
Deallocate region
|
|
Cleanup compiled query |
|
Delete table from the database
|
|
Detach thread from the database.
|
|
Drop hash table for the field
|
|
Drop T-Tree index for the field
|
|
Delete all table records
|
|
End transaction with specified thread context
|
|
End transaction |
|
Evaluate epression. This method initialie initiainherited attributes and invoke execute method
|
|
Execute expression. This method is most frequently recursivly called during evaluation of search predicate.
|
|
Check if there is inverse reference in the table rerefrenced from search predicate.
|
|
Checks whther allocated size is greater than size of databae file and recreate memory mapping object with larger size n the last case
|
|
Find table using symbol name
|
|
Find table by name. This method get symbol for specified name and call
|
|
If query predicate contains operands from other tables (accessed by references) and inverse references exists, then FastDB performs indexed search in referenced table and then go back using inverse referenced to query table. followInverseReference method performs this backward traversal of inverse references.
|
|
Free object identifier(s)
|
|
Free internal object |
|
Delete row from the table
|
|
Get record by OID
|
|
Get allocated size of the database
|
|
Get size of the database file
|
|
Get table row
|
|
Get database version |
|
Error handler. It can be redifined by application to implement application specific error handling.
|
|
Initialize database metatable (table containning information about all other tables included metatable itself). This method is invoked during database initialzation. |
|
Insert record in the database
|
|
Insert inverse reference. When reference or array of reference which is part of relation is updated then reference to the updated record is inserted in inverse reference field of all new referenced records (which were not referenced by this field before update).
|
|
Insert record in the database
|
|
Check whether expression can be evaluated unsing index. If index is applicable, than index search is performed and result is stored in the cursor.
|
|
Check whther search dan be performed using indices
|
|
Check if database is opened |
|
Link table to the database table list
|
|
Load database scheme. This method loads table decriptors from database, compare them with application classes, do necessary reformatting and save update andnew table decriptor in database
|
|
Exclusivly lock the database. |
|
Find cloned table desciptor assigned to this database
|
|
Open database
|
|
Release all locks hold by transaction allowing other clients to proceed but do not flush changes to the disk |
|
Prepare for update of internal object.
|
|
Prepare for object update ithout changing its size
|
|
Prepare for row insertion or update. If record with such OID not exists or it is first time when it was changed during this transaction or size of recrod is changed, than new record is alocated in the database. Otherwisepointer to existed recordis returned.
|
|
Perform database recovery after fault |
|
Reformat table according to new format
|
|
Remove record from the database
|
|
Remove inverse reference. When reference or array of reference which is part of relation is updated then reference to the updated record is removed from inverse reference field of all referenced records which are not reference any more from by this field.
|
|
Remove inverse references to the removed record
|
|
Mark location as reserved. This method is used by allocator to protect hole located in memory allocation bitmap, from been used by recursuve call of allocator (needed to clone bitmap pages).
|
|
Restore consistency of table list of rows (last record should contain null reference in next field). This method is used during recovery after crash and during rollback. |
|
Rollback transaction |
|
Schedule backup
|
|
Execute select query
|
|
Select all records from the table
|
|
Set concurrency level for sequential search and sort operations. By default, FastDB tries to detect number of CPUs in system and create the same number of threads.
|
|
Set error handler. Handler should be no-return function which perform stack unwind.
|
|
Specify database file size limit. Attempt to exeed this limit cause database error.
|
|
Perform table traverse: execute queries with "start from (follow by)" clause
|
|
Unlink table from the database tables list
|
|
Update record
|
|
Update record in in all active cursors if it this record is checnged in the database
|
|
Update database table descriptor
|
|
Check if location is reserved
|