#include <database.h>
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 | attach (dbDatabaseThreadContext *ctx) |
void | detach (int flags=COMMIT|DESTROY_CONTEXT) |
void | lock () |
bool | backup (char const *file, bool compactify) |
bool | backup (dbFile *file, bool compactify) |
void | assign (dbTableDescriptor &desc) |
void | setConcurrency (unsigned nThreads) |
long | getAllocatedSize () |
long | getDatabaseSize () |
int | getNumberOfReaders () |
int | getNumberOfWriters () |
int | getNumberOfBlockedReaders () |
int | getNumberOfBlockedWriters () |
int | getNumberOfUsers () |
void | allowColumnsDeletion (bool enabled=true) |
bool | prepareQuery (dbAnyCursor *cursor, dbQuery &query) |
dbErrorHandler | setErrorHandler (dbErrorHandler newHandler, void *errorHandlerContext=NULL) |
virtual void | handleError (dbErrorClass error, char const *msg=NULL, int arg=0) |
void | insertRecord (dbTableDescriptor *table, dbAnyReference *ref, void const *record) |
bool | isOpen () const |
bool | isCommitted () |
bool | isAttached () |
bool | isUpdateTransaction () |
int | getVersion () |
void | setFileSizeLimit (size_t limit) |
template<class T> dbReference< T > | insert (T const &record) |
dbTableDescriptor * | lookupTable (dbTableDescriptor *desc) |
void | getMemoryStatistic (dbMemoryStatistic &stat) |
dbDatabase (dbAccessType type=dbAllAccess, size_t dbInitSize=dbDefaultInitDatabaseSize, size_t dbExtensionQuantum=dbDefaultExtensionQuantum, size_t dbInitIndexSize=dbDefaultInitIndexSize, int nThreads=1) | |
virtual | ~dbDatabase () |
Protected Types | |
enum | dbLockType |
Protected Methods | |
dbTableDescriptor * | loadMetaTable () |
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 | isPrefixSearch (dbAnyCursor *cursor, dbExprNode *expr, dbExprNode *andExpr, dbFieldDescriptor *&indexedField) |
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, bool removed=false) |
void | recovery () |
bool | checkVersion () |
oid_t | allocateObject (dbInternalObject marker) |
oid_t | allocateRow (oid_t tableId, size_t size) |
void | allocateRow (oid_t tableId, oid_t oid, size_t size) |
void | freeRow (oid_t tableId, oid_t oid) |
void | freeObject (oid_t oid) |
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) |
dbTableDescriptor * | getTables () |
void | setDirty () |
Static Protected Methods | |
void _fastcall | execute (dbExprNode *expr, dbInheritedAttribute &iattr, dbSynthesizedAttribute &sattr) |
void | deleteCompiledQuery (dbExprNode *tree) |
|
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 record with specified OID
|
|
Allocate record
|
|
Enable deletion of columns from the table when correspondent fields are renamed from class descriptor. By default it is switched of and database allows to delete fields only from empty table (to prevent unindented loose of data).
|
|
Assign table to the database
|
|
Set transaction context for the current thread. Using this method allows to share the same transaction between different threads
|
|
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
|
|
Perform backup to the file with specified name
|
|
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.
|
|
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 size allocated in the database since open
|
|
Get size of the database file
|
|
Get information about state of database memory
|
|
Get number of threads blocked while starting read-only transaction
|
|
Get number of threads blocked while starting update transaction
|
|
Get number of threads accessing database in shared mode (readonly)
|
|
Get number of processes attached to the database
|
|
Get number of threads accessing database in exclusiveh mode (for update)
|
|
Get table row
|
|
Get list of tables attached to the database
|
|
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 if thread was attached to the database. Used mostly for debugging purposes. |
|
Check if current transaction is committed. Used mostly for debugging purposes. |
|
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 whether search can be performed using indices
|
|
Check if database is opened |
|
Check whether query is prefix search: "'key' like field+'%'"
|
|
Check if current transaction is updating database |
|
Link table to the database table list
|
|
Loads all class descriptors. This method should be used SubSQL and any other apllication which is should work with ANY database file.
|
|
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 query. This method can be used for explicit compilation of query and it's validation
|
|
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.
|
|
Mark database as been modified |
|
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
|