1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
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. *
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. *
15 ***************************************************************************/
16 #ifndef DATABASE_MANAGER_IMPL_H
17 #define DATABASE_MANAGER_IMPL_H
19 #include<CatalogTables.h>
21 #include<DatabaseManager.h>
23 //Note::DatabaseManagerImpl is used to hide functionalites from normal database user.
24 //User is exposed to DatabaseManagerImpl, for our tools we shall type cast DatabaseManager
25 //to DatabaseManagerImpl to retreive internal information such as db statistics, etc
33 class TransactionManager
;
37 CSqlProcInfo() { sysDbAttachAddr
= userDbAttachAddr
= NULL
;}
38 void *sysDbAttachAddr
;
39 void *userDbAttachAddr
;
43 static CSqlProcInfo csqlProcInfo
;
45 class DatabaseManagerImpl
: public DatabaseManager
48 Database
* systemDatabase_
;
49 //pointer to system Database
56 TransactionManager
*tMgr_
;
59 ProcessManager
*pMgr_
;
62 //only SessionImpl creates object of this class
63 DatabaseManagerImpl() { systemDatabase_
= NULL
; tMgr_
= NULL
; lMgr_
= NULL
;
64 pMgr_
= NULL
; db_
= NULL
; }
65 ~DatabaseManagerImpl();
67 DbRetVal
openSystemDatabase();
68 DbRetVal
closeSystemDatabase();
69 ChunkIterator
getSystemTableIterator(CatalogTableID id
);
70 Chunk
* getSystemTableChunk(CatalogTableID id
);
72 void createLockManager();
73 void createTransactionManager();
75 Chunk
* createUserChunk(size_t size
= 0);
76 DbRetVal
deleteUserChunk(Chunk
*chunk
);
79 DbRetVal
createHashIndex(const char *indName
, const char *tableName
,
80 FieldNameList
&fldList
, int bucketSize
, bool isUnique
, bool isPrimary
= false);
81 void initHashBuckets(Bucket
*buck
, int bucketSize
);
83 DbRetVal
dropIndexInt(const char *name
, bool takeLock
);
87 Database
* db() { return db_
; }
88 Database
* sysDb() { return systemDatabase_
; }
89 void setSysDb(Database
*db
) { systemDatabase_
= db
; }
90 void setDb(Database
*db
) { db_
= db
; }
93 TransactionManager
* txnMgr() { return tMgr_
; }
94 LockManager
* lockMgr() { return lMgr_
; }
96 //for user database file there is no limit for the number
98 DbRetVal
createDatabase(const char *name
, size_t size
);
99 DbRetVal
deleteDatabase(const char *name
);
101 DbRetVal
openDatabase(const char *name
);
102 DbRetVal
closeDatabase();
106 DbRetVal
createTable(const char *name
, TableDef
&def
);
107 DbRetVal
dropTable(const char *name
);
108 Table
* openTable(const char *name
);
109 void closeTable(Table
*table
);
110 DbRetVal
createIndex(const char *indName
, IndexInitInfo
*info
);
111 DbRetVal
dropIndex(const char *name
);
112 List
getAllTableNames();
114 DbRetVal
registerThread();
115 DbRetVal
deregisterThread();
116 bool isAnyOneRegistered();
117 void printUsageStatistics();
118 void printDebugLockInfo();
119 void printDebugTransInfo();
120 void printDebugChunkInfo();
121 void printDebugProcInfo();
122 DbRetVal
printIndexInfo(char *name
);
123 friend class SessionImpl
;