include/DatabaseManagerImpl.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015   ***************************************************************************/
00016 #ifndef DATABASE_MANAGER_IMPL_H
00017 #define DATABASE_MANAGER_IMPL_H
00018 #include<os.h>
00019 #include<CatalogTables.h>
00020 #include<Lock.h>
00021 #include<DatabaseManager.h>
00022 #include<Process.h>
00023 //Note::DatabaseManagerImpl is used to hide functionalites from normal database user. 
00024 //User is exposed to DatabaseManagerImpl, for our tools we shall type cast DatabaseManager 
00025 //to DatabaseManagerImpl to retreive internal information such as db statistics, etc
00026 class Database;
00027 class SessionImpl;
00028 class TableDef;
00029 class Table;
00030 class FieldNameList;
00031 class ChunkIterator;
00032 class Chunk;
00033 class TransactionManager;
00034 class CSqlProcInfo
00035 {
00036     public:
00037     CSqlProcInfo() { sysDbAttachAddr = userDbAttachAddr = NULL;}
00038     void *sysDbAttachAddr;
00039     void *userDbAttachAddr;
00040 };
00041 
00042 //Global object
00043 static CSqlProcInfo csqlProcInfo;
00044 
00045 class DatabaseManagerImpl : public DatabaseManager
00046 {
00047     private:
00048     Database* systemDatabase_;
00049     //pointer to system Database
00050 
00051     Database* db_;
00052     //pointer to database
00053 
00054     LockManager *lMgr_;
00055 
00056     TransactionManager *tMgr_;
00057 
00058 
00059     ProcessManager *pMgr_;
00060     int procSlot;
00061 
00062     //only SessionImpl creates object of this class
00063     DatabaseManagerImpl() { systemDatabase_ = NULL; tMgr_ = NULL; lMgr_ =  NULL; 
00064                             pMgr_ = NULL; db_ = NULL; }
00065     ~DatabaseManagerImpl();
00066 
00067     DbRetVal openSystemDatabase();
00068     DbRetVal closeSystemDatabase();
00069     ChunkIterator getSystemTableIterator(CatalogTableID id);
00070     Chunk* getSystemTableChunk(CatalogTableID id);
00071 
00072     void createLockManager();
00073     void createTransactionManager();
00074 
00075     Chunk* createUserChunk(size_t size = 0);
00076     DbRetVal deleteUserChunk(Chunk *chunk);
00077 
00078 
00079     DbRetVal createHashIndex(const char *indName, const char *tableName,
00080                         FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false);
00081     void initHashBuckets(Bucket *buck, int bucketSize);
00082 
00083     DbRetVal dropIndexInt(const char *name, bool takeLock);
00084 
00085     public:
00086 
00087     Database* db() { return db_; }
00088     Database* sysDb() { return systemDatabase_; }
00089     void setSysDb(Database *db) { systemDatabase_ = db; }
00090     void setDb(Database *db) { db_ = db; }
00091 
00092     void setProcSlot();
00093     TransactionManager* txnMgr() { return tMgr_; }
00094     LockManager* lockMgr() { return lMgr_; }
00095 
00096     //for user database file there is no limit for the number
00097     //of tables or chunks
00098     DbRetVal createDatabase(const char *name, size_t size);
00099     DbRetVal deleteDatabase(const char *name);
00100 
00101     DbRetVal openDatabase(const char *name);
00102     DbRetVal closeDatabase();
00103 
00104 
00105 
00106     DbRetVal createTable(const char *name, TableDef &def);
00107     DbRetVal dropTable(const char *name);
00108     Table* openTable(const char *name);
00109     void closeTable(Table *table);
00110     DbRetVal createIndex(const char *indName, IndexInitInfo *info);
00111     DbRetVal dropIndex(const char *name);
00112     List getAllTableNames();
00113 
00114     DbRetVal registerThread();
00115     DbRetVal deregisterThread();
00116     bool isAnyOneRegistered();
00117     void printUsageStatistics();
00118     void printDebugLockInfo();
00119     void printDebugTransInfo();
00120     void printDebugChunkInfo();
00121     void printDebugProcInfo();
00122     DbRetVal printIndexInfo(char *name);
00123     friend class SessionImpl;
00124 };
00125 #endif

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7