cases for module sqlnetwork/Parameter
[csql.git] / include / DatabaseManagerImpl.h
blobc623b97bc4cd57e04bb31691ba86f0fceaf8951a
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef DATABASE_MANAGER_IMPL_H
17 #define DATABASE_MANAGER_IMPL_H
18 #include<os.h>
19 #include<CatalogTables.h>
20 #include<Lock.h>
21 #include<DatabaseManager.h>
22 #include<Process.h>
23 #include<Util.h>
24 //Note::DatabaseManagerImpl is used to hide functionalites from normal database user.
25 //User is exposed to DatabaseManagerImpl, for our tools we shall type cast DatabaseManager
26 //to DatabaseManagerImpl to retreive internal information such as db statistics, etc
27 class Database;
28 class SessionImpl;
29 class TableDef;
30 class Table;
31 class FieldNameList;
32 class ChunkIterator;
33 class Chunk;
34 class TransactionManager;
35 class CSqlProcInfo
37 public:
38 CSqlProcInfo() { sysDbAttachAddr = userDbAttachAddr = NULL;}
39 void *sysDbAttachAddr;
40 void *userDbAttachAddr;
43 //Global object
44 static CSqlProcInfo csqlProcInfo;
46 class DatabaseManagerImpl : public DatabaseManager
48 private:
49 Database* systemDatabase_;
50 //pointer to system Database
52 Database* db_;
53 //pointer to database
55 LockManager *lMgr_;
57 TransactionManager *tMgr_;
60 ProcessManager *pMgr_;
61 int procSlot;
63 List tableHandleList; // list of table handles
65 //only SessionImpl creates object of this class
66 DatabaseManagerImpl() { systemDatabase_ = NULL; tMgr_ = NULL; lMgr_ = NULL;
67 pMgr_ = NULL; db_ = NULL; }
68 ~DatabaseManagerImpl();
70 DbRetVal openSystemDatabase();
71 DbRetVal closeSystemDatabase();
72 ChunkIterator getSystemTableIterator(CatalogTableID id);
73 Chunk* getSystemTableChunk(CatalogTableID id);
75 void createLockManager();
76 void createTransactionManager();
78 Chunk* createUserChunk(size_t size = 0);
79 DbRetVal deleteUserChunk(Chunk *chunk);
82 DbRetVal createHashIndex(const char *indName, const char *tableName,
83 FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false);
84 DbRetVal createTreeIndex(const char *indName, const char *tableName,
85 FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false);
86 void initHashBuckets(Bucket *buck, int bucketSize);
88 DbRetVal dropIndexInt(const char *name, bool takeLock);
90 public:
92 Database* db() { return db_; }
93 Database* sysDb() { return systemDatabase_; }
94 void setSysDb(Database *db) { systemDatabase_ = db; }
95 void setDb(Database *db) { db_ = db; }
97 void setProcSlot();
98 TransactionManager* txnMgr() { return tMgr_; }
99 LockManager* lockMgr() { return lMgr_; }
101 //for user database file there is no limit for the number
102 //of tables or chunks
103 DbRetVal createDatabase(const char *name, size_t size);
104 DbRetVal deleteDatabase(const char *name);
106 DbRetVal openDatabase(const char *name);
107 DbRetVal closeDatabase();
111 DbRetVal createTable(const char *name, TableDef &def);
112 DbRetVal dropTable(const char *name);
113 Table* openTable(const char *name);
114 void closeTable(Table *table);
115 DbRetVal createIndex(const char *indName, IndexInitInfo *info);
116 DbRetVal dropIndex(const char *name);
117 List getAllTableNames();
119 DbRetVal registerThread();
120 DbRetVal deregisterThread();
121 bool isAnyOneRegistered();
122 void printUsageStatistics();
123 void printDebugLockInfo();
124 void printDebugTransInfo();
125 void printDebugChunkInfo();
126 void printDebugProcInfo();
127 DbRetVal printIndexInfo(char *name);
128 friend class SessionImpl;
130 #endif