![]() |
Quadcap Embeddable Database |
Inheritance diagram for com.quadcap.sql.Database:

Definition at line 86 of file Database.java.
Public Member Functions | |
| Database () | |
| Constructor. | |
| void | init (QDriver driver, String url, String fileName, Properties props) throws IOException, SQLException |
| void | createRoot (String fileName, Properties props) throws IOException |
| Create a new root block. | |
| void | readRoot () throws IOException |
| Read the root block from an existing database. | |
| void | flushRoot () throws IOException |
| Write the database root. | |
| void | bootFromRoot (boolean restart) throws IOException |
| Get ready to rumble!!! | |
| long | getNextTransId () throws IOException |
| Return the next available transaction ID. | |
| void | maybeBackup () throws IOException |
| Figure out if it's time to do a backup. | |
| void | addIndex (String indexName, String tableName) throws IOException |
| TODO: XXX Unicode!!! Add a new named index for the specified table. | |
| String | getTableForIndex (String indexName) throws IOException |
| Return the table for the index of the specified name. | |
| void | deleteIndex (String indexName) throws IOException |
| Remove the specified index. | |
| long | getTableIdentity (String name) throws IOException, SQLException |
| Return the table identity for the table. | |
| void | updateTableIdentity (String name, long num) throws IOException, SQLException |
| The "table identity" is a long value stored along with the table stream pointer, so that it can easily be updated as long as the index is in memory, without touching any data pages. | |
| java.sql.ResultSet | execute (String sql) throws SQLException, IOException |
| Helper to execute a single SQL statement (in its own connection) and return a result set. | |
| java.sql.ResultSet | execute (Session session, String sql) throws IOException, SQLException |
| Helper to execute a single SQL statement for the given session. | |
| Relation | getRelation (String name) throws IOException |
| Return the table/view with the specified name. | |
| void | addRelation (Relation table) throws IOException, SQLException |
| Add a new table/view '. | |
| void | removeRelation (String name) throws IOException, SQLException |
| Delete the specified table/view. | |
| void | renameRelation (Relation r, String newN) throws IOException |
| Rename a relation. | |
| void | updateRelation (Relation table) throws IOException |
| Store a modified version of the specified view/table to the store. | |
| void | addViewDependency (String base, String view) throws IOException |
| Establish the dependency link between a view and a base table. | |
| void | checkViewDependency (String base, String view) throws SQLException, IOException |
| Make sure that the specified view dependency is valid. | |
| Enumeration | getViews (String base) throws IOException |
| Return an enumeration of all views for the specified base table. | |
| Enumeration | getBases (String view) throws IOException |
| Return an enumeration containing all base tables for the specified view. | |
| void | removeViewDependencies (String view) throws SQLException, IOException |
| Iterator | getRelationNameIterator () throws IOException |
| This hacky crack of encapsulation is for sql.meta.MetaTables, to support DatabaseMetaData.getTables(). | |
| int | addConnection () |
| Add a new connection (just remember the count...). | |
| QDriver | getDriver () |
| Sleight of hand to get my driver interface. | |
| void | removeConnection () |
| Remove a connection. | |
| int | getConnectionCount () |
| Return the number of active connections. | |
| String | getBackupDir () |
| Return the backup directory name. | |
| void | setBackupDir (String str) throws IOException |
| Set the backup directory. | |
| int | getBackupCount () |
| Return the backup count. | |
| void | setBackupCount (int count) throws IOException |
| Set the backup count. | |
| int | getBackupDays () |
| Return the backup days. | |
| void | setBackupDays (int count) throws IOException |
| Set the backup days. | |
| int | getBackupLastDay () |
| Return the backup last day. | |
| void | setBackupLastDay (int day) throws IOException |
| Set the backup last day. | |
| int | getBackupTime () |
| Return the backup time. | |
| void | setBackupTime (int time) throws IOException |
| Set the backup time. | |
| String | getBackupFormat () |
| Return the backup format. | |
| void | setBackupFormat (String str) throws IOException |
| Set the backup format. | |
| void | checkAuth (String user, String passwd) throws SQLException |
| Check the specified authentication credentials; throw an exception if authorization shouldn't be granted. | |
| int | getPermBlobRefCount (long blob) throws IOException |
| Return the current persistent refcount for the specified blob. | |
| int | refCountBlob (long transId, long blob, int incr) throws IOException |
| void | addMorgue (long blob, long transId) |
| Add a blob/clob to the morgue. | |
| void | delMorgue (long blob) |
| Remove a blob/clob from the morgue. | |
| LongIterator | enumerateMorgue () |
| Enumerate the morgue. | |
| void | checkpointHandler (LongMap activeTransactions) throws IOException |
| Called during a checkpoint operation. | |
| void | emptyMorgue (LongMap activeTransactions) throws IOException |
| Empty the BLOB morgue. | |
| void | display (PrintWriter w) throws IOException |
| long | putRow (Session session, BlockFile f, Tuple t, Row row) throws SQLException, IOException |
| Convenience method to write a new row to the database. | |
| final void | putRow (Session session, Tuple t, long rowId, Row row) throws SQLException, IOException |
| Convenience method to update a table row. | |
| void | getRow (long rowId, LazyRow row, boolean isTemp) throws IOException, SQLException |
| void | removeRow (long rowId) throws IOException |
| void | removeRow (BlockFile file, long rowId) throws IOException |
| boolean | inMemory () |
Public Attributes | |
| DatabaseRoot | nroot |
| Object | driverLock |
Package Functions | |
| File | makeBackupFile (int n) throws IOException |
| void | renameIndexedTable (String oldN, String newN) throws IOException |
| RENAME TABLE percolates into the index index... | |
| final Session | getSession (Transaction t) throws IOException, SQLException |
Package Attributes | |
| QDriver | driver |
| Btree | tableIndex |
| Btree | indexIndex |
| Btree | blobPermRefCounts |
| Map | tableMap = new HashMap() |
| MultiSet | forwardDeps = null |
| MultiSet | reverseDeps = null |
| long | rootBlock = 0 |
| LongMap | blobMorgue = new LongMap(32) |
| The Morgue; BLOB/CLOBs with zero (persistent) refcounts: blobRef -> any. | |
| LongMap | blobActivity = new LongMap(128) |
| Map blob -> Vector<transid>. | |
| int | connectionCount = 0 |
| int | closeCount = 0 |
| long | nextTransId = 0 |
| Session | zSession = null |
| Connection | zConn = null |
Static Package Attributes | |
| final ConfigString | backupClass |
Private Attributes | |
| byte[] | key = new byte[8] |
|
|
Constructor.
Definition at line 118 of file Database.java. |
|
|
Add a new connection (just remember the count...).
Definition at line 756 of file Database.java. References com.quadcap.sql.Database.connectionCount, and com.quadcap.sql.Database.driverLock. Referenced by com.quadcap.jdbc.JdbcDriver.connect(). |
|
||||||||||||
|
TODO: XXX Unicode!!! Add a new named index for the specified table.
Definition at line 261 of file Database.java. References com.quadcap.sql.Database.addIndex(), and com.quadcap.sql.Database.indexIndex. Referenced by com.quadcap.sql.Database.addIndex(), com.quadcap.sql.AddConstraint.redo(), and com.quadcap.sql.DeleteConstraint.undo(). |
|
||||||||||||
|
Add a blob/clob to the morgue.
Definition at line 963 of file Database.java. References com.quadcap.sql.Database.addMorgue(), and com.quadcap.sql.Database.blobMorgue. Referenced by com.quadcap.sql.Database.addMorgue(), and com.quadcap.sql.Database.refCountBlob(). |
|
|
Add a new table/view '.
Definition at line 444 of file Database.java. References com.quadcap.sql.Database.addRelation(), com.quadcap.sql.Tuple.getName(), com.quadcap.sql.Database.inMemory(), com.quadcap.sql.index.BCursor.insert(), com.quadcap.sql.index.BCursor.release(), com.quadcap.sql.index.BCursor.seek(), com.quadcap.sql.Database.tableIndex, and com.quadcap.sql.Database.tableMap. Referenced by com.quadcap.sql.Database.addRelation(), com.quadcap.sql.StmtCreateView.redo(), com.quadcap.sql.AddTable.redo(), and com.quadcap.sql.DropTable.undo(). |
|
||||||||||||
|
Establish the dependency link between a view and a base table.
Definition at line 587 of file Database.java. References com.quadcap.sql.Database.addViewDependency(), com.quadcap.sql.Database.forwardDeps, com.quadcap.sql.MultiSet.put(), and com.quadcap.sql.Database.reverseDeps. Referenced by com.quadcap.sql.Database.addViewDependency(), com.quadcap.sql.StmtCreateView.redo(), and com.quadcap.sql.DropTable.undo(). |
|
|
||||||||||||
|
Check the specified authentication credentials; throw an exception if authorization shouldn't be granted. We really don't care about passwords. This is an embedded database, remember; it's really just a fancy API on top of a simple file! Definition at line 901 of file Database.java. References com.quadcap.sql.Database.checkAuth(). Referenced by com.quadcap.sql.Database.checkAuth(), and com.quadcap.sql.Connection.setAuth(). |
|
|
Called during a checkpoint operation.
Definition at line 991 of file Database.java. References com.quadcap.sql.Database.checkpointHandler(), and com.quadcap.sql.Database.emptyMorgue(). Referenced by com.quadcap.sql.Database.checkpointHandler(). |
|
||||||||||||
|
Make sure that the specified view dependency is valid.
Definition at line 605 of file Database.java. References com.quadcap.sql.Database.checkViewDependency(), and com.quadcap.sql.Table.getModifiers(). Referenced by com.quadcap.sql.Database.checkViewDependency(), and com.quadcap.sql.StmtCreateView.redo(). |
|
||||||||||||
|
Create a new root block.
Definition at line 131 of file Database.java. References com.quadcap.sql.Database.createRoot(), com.quadcap.sql.Database.flushRoot(), and com.quadcap.sql.Database.inMemory(). Referenced by com.quadcap.sql.Database.createRoot(). |
|
|
Remove the specified index.
Definition at line 284 of file Database.java. References com.quadcap.sql.Database.deleteIndex(), and com.quadcap.sql.Database.indexIndex. Referenced by com.quadcap.sql.Database.deleteIndex(), com.quadcap.sql.DeleteConstraint.redo(), and com.quadcap.sql.AddConstraint.undo(). |
|
|
Remove a blob/clob from the morgue.
Definition at line 972 of file Database.java. References com.quadcap.sql.Database.blobMorgue, and com.quadcap.sql.Database.delMorgue(). Referenced by com.quadcap.sql.Database.delMorgue(), com.quadcap.sql.Database.refCountBlob(), and com.quadcap.sql.InsertBlob.undo(). |
|
|
|
Empty the BLOB morgue. Remove any BLOBS in the morge that were deleted by transactions which have committed. Definition at line 1001 of file Database.java. References com.quadcap.sql.Database.blobMorgue, com.quadcap.sql.Database.emptyMorgue(), com.quadcap.sql.Database.enumerateMorgue(), and com.quadcap.util.collections.LongIterator.nextLong(). Referenced by com.quadcap.sql.Database.checkpointHandler(), and com.quadcap.sql.Database.emptyMorgue(). |
|
|
Enumerate the morgue.
Definition at line 981 of file Database.java. References com.quadcap.sql.Database.blobMorgue. Referenced by com.quadcap.sql.Database.emptyMorgue(). |
|
||||||||||||
|
Helper to execute a single SQL statement for the given session.
Definition at line 388 of file Database.java. References com.quadcap.sql.Database.execute(), and com.quadcap.sql.SQLParser.statement(). |
|
|
Helper to execute a single SQL statement (in its own connection) and return a result set.
Definition at line 377 of file Database.java. References com.quadcap.sql.Connection.createSession(), and com.quadcap.sql.Database.execute(). Referenced by com.quadcap.sql.Database.execute(). |
|
|
Write the database root.
Definition at line 154 of file Database.java. References com.quadcap.sql.Database.inMemory(), and com.quadcap.sql.Database.rootBlock. Referenced by com.quadcap.sql.Database.createRoot(), com.quadcap.sql.Database.getNextTransId(), com.quadcap.sql.Database.setBackupCount(), com.quadcap.sql.Database.setBackupDays(), com.quadcap.sql.Database.setBackupDir(), com.quadcap.sql.Database.setBackupFormat(), com.quadcap.sql.Database.setBackupLastDay(), and com.quadcap.sql.Database.setBackupTime(). |
|
|
Return the backup count.
Definition at line 822 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupCount(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.maybeBackup(). |
|
|
Return the backup days.
Definition at line 837 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupDays(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.maybeBackup(). |
|
|
Return the backup directory name.
Definition at line 807 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupDir(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.makeBackupFile(). |
|
|
Return the backup format.
Definition at line 882 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupFormat(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.makeBackupFile(), and com.quadcap.sql.Database.maybeBackup(). |
|
|
Return the backup last day.
Definition at line 852 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupLastDay(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.maybeBackup(). |
|
|
Return the backup time.
Definition at line 867 of file Database.java. References com.quadcap.sql.DatabaseRoot.getBackupTime(), and com.quadcap.sql.Database.nroot. Referenced by com.quadcap.sql.Database.maybeBackup(). |
|
|
Return an enumeration containing all base tables for the specified view.
Definition at line 635 of file Database.java. References com.quadcap.sql.MultiSet.get(), com.quadcap.sql.Database.getBases(), and com.quadcap.sql.Database.reverseDeps. Referenced by com.quadcap.sql.Database.getBases(), and com.quadcap.sql.DropTable.prepare(). |
|
|
Return the number of active connections.
Definition at line 800 of file Database.java. References com.quadcap.sql.Database.connectionCount. |
|
|
Sleight of hand to get my driver interface.
Definition at line 770 of file Database.java. References com.quadcap.sql.Database.driver. Referenced by com.quadcap.sql.SelectStmt.execute(). |
|
|
Return the next available transaction ID.
Definition at line 182 of file Database.java. References com.quadcap.sql.Database.flushRoot(), com.quadcap.sql.Database.inMemory(), com.quadcap.sql.Database.nextTransId, com.quadcap.sql.Database.nroot, and com.quadcap.sql.DatabaseRoot.setNextTransId(). |
|
|
Return the current persistent refcount for the specified blob.
Definition at line 908 of file Database.java. References com.quadcap.sql.Database.blobPermRefCounts, com.quadcap.sql.Database.getPermBlobRefCount(), and com.quadcap.sql.Database.key. Referenced by com.quadcap.sql.Database.getPermBlobRefCount(). |
|
|
|
This hacky crack of encapsulation is for sql.meta.MetaTables, to support DatabaseMetaData.getTables(). All he really needs is an Iterator which returns the table names.... Definition at line 671 of file Database.java. References com.quadcap.sql.index.BCursor.delete(), com.quadcap.sql.index.BCursor.getKey(), com.quadcap.sql.Database.inMemory(), com.quadcap.sql.index.BCursor.next(), com.quadcap.sql.index.BCursor.release(), com.quadcap.sql.Database.tableIndex, and com.quadcap.sql.Database.tableMap. Referenced by com.quadcap.sql.meta.MetaColumns.MetaColumns(), com.quadcap.sql.meta.MetaCrossReference.MetaCrossReference(), com.quadcap.sql.meta.MetaIndexInfo.MetaIndexInfo(), com.quadcap.sql.meta.MetaPrimaryKeys.MetaPrimaryKeys(), com.quadcap.sql.meta.MetaSchemas.MetaSchemas(), and com.quadcap.sql.meta.MetaTables.MetaTables(). |
|
||||||||||||||||
|
|
|
Return the table for the index of the specified name.
Definition at line 273 of file Database.java. References com.quadcap.sql.Database.getTableForIndex(), and com.quadcap.sql.Database.indexIndex. Referenced by com.quadcap.sql.StmtDropIndex.execute(), com.quadcap.sql.StmtCreateIndex.execute(), and com.quadcap.sql.Database.getTableForIndex(). |
|
|
Return the table identity for the table.
Definition at line 318 of file Database.java. References com.quadcap.sql.Database.getRelation(), com.quadcap.sql.Database.getTableIdentity(), com.quadcap.sql.index.BCursor.getValBuf(), com.quadcap.sql.index.BCursor.getValLen(), com.quadcap.sql.Database.inMemory(), com.quadcap.sql.index.BCursor.release(), com.quadcap.sql.index.BCursor.seek(), com.quadcap.sql.Table.tableIdentity, and com.quadcap.sql.Database.tableIndex. Referenced by com.quadcap.sql.AutoNumberConstraint.checkInsert(), and com.quadcap.sql.Database.getTableIdentity(). |
|
|
Return an enumeration of all views for the specified base table.
Definition at line 625 of file Database.java. References com.quadcap.sql.Database.forwardDeps, com.quadcap.sql.MultiSet.get(), and com.quadcap.sql.Database.getViews(). Referenced by com.quadcap.sql.StmtDropTable.execute(), com.quadcap.sql.Database.getViews(), and com.quadcap.sql.StmtRenameTable.rename(). |
|
||||||||||||||||||||
|
Definition at line 120 of file Database.java. References com.quadcap.sql.Database.driver, and com.quadcap.sql.Database.init(). Referenced by com.quadcap.jdbc.JdbcDriver.connect(), and com.quadcap.sql.Database.init(). |
|
|
|
Definition at line 245 of file Database.java. References com.quadcap.sql.Database.getBackupDir(), com.quadcap.sql.Database.getBackupFormat(), and com.quadcap.sql.Database.makeBackupFile(). Referenced by com.quadcap.sql.Database.makeBackupFile(), and com.quadcap.sql.Database.maybeBackup(). |
|
|
||||||||||||||||||||
|
Convenience method to update a table row.
Definition at line 1108 of file Database.java. References com.quadcap.sql.Database.inMemory(). |
|
||||||||||||||||||||
|
Convenience method to write a new row to the database.
Definition at line 1083 of file Database.java. References com.quadcap.sql.Database.inMemory(), and com.quadcap.sql.Database.putRow(). Referenced by com.quadcap.sql.TempTableMerge.addRows(), com.quadcap.sql.TempTable.addRows(), com.quadcap.sql.JoinInnerCursor.makeTemporaryIndexForView(), com.quadcap.sql.InsertRow.prepare(), com.quadcap.sql.Database.putRow(), com.quadcap.sql.UpdateRow.redo(), com.quadcap.sql.UpdateRow.undo(), and com.quadcap.sql.DeleteRow.undo(). |
|
|
Read the root block from an existing database.
Definition at line 145 of file Database.java. References com.quadcap.sql.Database.nroot, and com.quadcap.sql.Database.rootBlock. |
|
||||||||||||||||
|
Definition at line 924 of file Database.java. References com.quadcap.sql.Database.addMorgue(), com.quadcap.sql.Database.blobPermRefCounts, com.quadcap.sql.Database.delMorgue(), com.quadcap.sql.Database.key, and com.quadcap.sql.Database.refCountBlob(). Referenced by com.quadcap.sql.RefcountBlob.redo(), com.quadcap.sql.Database.refCountBlob(), and com.quadcap.sql.RefcountBlob.undo(). |
|
|
Remove a connection. If the connection count drops to zero, we get crafty. Definition at line 778 of file Database.java. References com.quadcap.sql.Database.closeCount, com.quadcap.sql.QDriver.closeDatabase(), com.quadcap.sql.Database.connectionCount, com.quadcap.sql.Database.driver, and com.quadcap.sql.Database.driverLock. Referenced by com.quadcap.sql.Connection.close(), and com.quadcap.jdbc.JdbcDriver.connect(). |
|
|
||||||||||||
|
Definition at line 1163 of file Database.java. References com.quadcap.sql.Database.inMemory(). |
|
|
Definition at line 1159 of file Database.java. References com.quadcap.sql.Database.removeRow(). Referenced by com.quadcap.sql.JoinInnerCursor.freeRows(), com.quadcap.sql.DeleteRow.redo(), com.quadcap.sql.Database.removeRow(), and com.quadcap.sql.InsertRow.undo(). |
|
|
Definition at line 641 of file Database.java. References com.quadcap.sql.MultiSet.delete(), com.quadcap.sql.Database.forwardDeps, and com.quadcap.sql.Database.removeViewDependencies(). Referenced by com.quadcap.sql.Database.removeRelation(), and com.quadcap.sql.Database.removeViewDependencies(). |
|
||||||||||||
|
RENAME TABLE percolates into the index index...
Definition at line 293 of file Database.java. References com.quadcap.sql.index.BCursor.getVal(), com.quadcap.sql.Database.indexIndex, com.quadcap.sql.index.BCursor.next(), com.quadcap.sql.index.BCursor.prev(), com.quadcap.sql.index.BCursor.release(), com.quadcap.sql.Database.renameIndexedTable(), and com.quadcap.sql.index.BCursor.replace(). Referenced by com.quadcap.sql.Database.renameIndexedTable(). |
|