Adding tests for composite keys
[csql.git] / include / DatabaseManagerImpl.h
blob50d1cac9d7258a46c8acac3ea6ff551af120573c
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 //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
26 class Database;
27 class SessionImpl;
28 class TableDef;
29 class Table;
30 class FieldNameList;
31 class ChunkIterator;
32 class Chunk;
33 class TransactionManager;
34 class CSqlProcInfo
36 public:
37 CSqlProcInfo() { sysDbAttachAddr = userDbAttachAddr = NULL;}
38 void *sysDbAttachAddr;
39 void *userDbAttachAddr;
42 //Global object
43 static CSqlProcInfo csqlProcInfo;
45 class DatabaseManagerImpl : public DatabaseManager
47 private:
48 Database* systemDatabase_;
49 //pointer to system Database
51 Database* db_;
52 //pointer to database
54 LockManager *lMgr_;
56 TransactionManager *tMgr_;
59 ProcessManager *pMgr_;
60 int procSlot;
62 List tableList; // list of table handles
64 //only SessionImpl creates object of this class
65 DatabaseManagerImpl() { systemDatabase_ = NULL; tMgr_ = NULL; lMgr_ = NULL;
66 pMgr_ = NULL; db_ = NULL; }
67 ~DatabaseManagerImpl();
69 DbRetVal openSystemDatabase();
70 DbRetVal closeSystemDatabase();
71 ChunkIterator getSystemTableIterator(CatalogTableID id);
72 Chunk* getSystemTableChunk(CatalogTableID id);
74 void createLockManager();
75 void createTransactionManager();
77 Chunk* createUserChunk(size_t size = 0);
78 DbRetVal deleteUserChunk(Chunk *chunk);
81 DbRetVal createHashIndex(const char *indName, const char *tableName,
82 FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false);
83 void initHashBuckets(Bucket *buck, int bucketSize);
85 DbRetVal dropIndexInt(const char *name, bool takeLock);
87 public:
89 Database* db() { return db_; }
90 Database* sysDb() { return systemDatabase_; }
91 void setSysDb(Database *db) { systemDatabase_ = db; }
92 void setDb(Database *db) { db_ = db; }
94 void setProcSlot();
95 TransactionManager* txnMgr() { return tMgr_; }
96 LockManager* lockMgr() { return lMgr_; }
98 //for user database file there is no limit for the number
99 //of tables or chunks
100 DbRetVal createDatabase(const char *name, size_t size);
101 DbRetVal deleteDatabase(const char *name);
103 DbRetVal openDatabase(const char *name);
104 DbRetVal closeDatabase();
108 DbRetVal createTable(const char *name, TableDef &def);
109 DbRetVal dropTable(const char *name);
110 Table* openTable(const char *name);
111 void closeTable(Table *table);
112 DbRetVal createIndex(const char *indName, IndexInitInfo *info);
113 DbRetVal dropIndex(const char *name);
114 List getAllTableNames();
116 DbRetVal registerThread();
117 DbRetVal deregisterThread();
118 bool isAnyOneRegistered();
119 void printUsageStatistics();
120 void printDebugLockInfo();
121 void printDebugTransInfo();
122 void printDebugChunkInfo();
123 void printDebugProcInfo();
124 DbRetVal printIndexInfo(char *name);
125 friend class SessionImpl;
127 #endif