allocator fixes
[csql.git] / include / CacheTableLoader.h
blob0ee61f36cc995e7a497d24bc1c75e1275c046de3
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 CACHETABLELOADER_H
17 #define CACHETABLELOADER_H
18 #include <CSql.h>
19 #include <sql.h>
20 #include <sqlext.h>
21 #include <Network.h>
23 class CacheIndexInfo
25 public:
26 char indexName[IDENTIFIER_LENGTH];
27 FieldNameList fieldList;
30 class CacheTableLoader
32 char tableName[IDENTIFIER_LENGTH];
33 char fieldName[IDENTIFIER_LENGTH];
34 char userName[IDENTIFIER_LENGTH];
35 char password[IDENTIFIER_LENGTH];
36 char conditionVal[IDENTIFIER_LENGTH]; //added newly
37 char fieldlistVal[IDENTIFIER_LENGTH];
38 char dsnName[IDENTIFIER_LENGTH];
39 // char dsnId[IDENTIFIER_LENGTH];
40 // char dsnPwd[IDENTIFIER_LENGTH];
41 bool shouldForce;
42 public:
43 CacheTableLoader()
45 strcpy(tableName,"");
46 strcpy(conditionVal,"");
47 strcpy(fieldName,"");
48 strcpy(fieldlistVal,"");
49 strcpy(dsnName,"");
50 //strcpy(dsnId,"");
51 //strcpy(dsnPwd,"");
52 shouldForce = false;
54 DbRetVal checkSecondTimeSqlPrimaryKeys(SQLHSTMT hstmtmeta,char *tableName,char *ptr, HashIndexInitInfo *inf,bool &isPriIndex);
55 DbRetVal createIndex(SQLHSTMT hstmtmeta, char *tableName, HashIndexInitInfo *inf,AbsSqlStatement *stmt,bool isPKFieldSpecified);
56 void setForceFlag(bool flag){ shouldForce = flag;}
57 void setConnParam(char *user, char *pass){ strcpy(userName, user); strcpy(password, pass); }
58 void setTable(char *tablename) { strcpy(tableName,tablename); }
59 void setCondition(char *condition){strcpy(conditionVal,condition);} //new one
60 void setDsnName(char *dname) {strcpy(dsnName,dname);}
62 //void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
63 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
64 void setFieldName(char *fldname){ strcpy(fieldName,fldname);}
65 DbRetVal addToCacheTableFile(bool isDirect);
66 void setFieldListVal(char *field) {strcpy(fieldlistVal,field);}
68 DbRetVal addToCacheTableFile();
69 DbRetVal removeFromCacheTableFile();
70 DbRetVal load(bool tabDef=true);
71 DbRetVal reload();
72 DbRetVal unload(bool tabDefinition = true);
73 DbRetVal refresh();
74 DbRetVal recoverAllCachedTables();
75 DbRetVal load(AbsSqlConnection *conn, AbsSqlStatement *stmt, bool tabDef);
76 DbRetVal isTablePresent();// new one by :Jitendra
77 DbRetVal CacheInfo(bool isTabPresent);
78 DbRetVal tablesOnDsn();
79 char *getConditionVal(char *condition);
80 void setParamValues(AbsSqlStatement *stmt, int parampos, DataType type, int length, char *value);
81 DbRetVal checkingSchema(SQLHDBC hdbc,SQLHSTMT hstmt,AbsSqlConnection *conn, AbsSqlStatement *stmt,TDBInfo tdbName);
82 DbRetVal cacheAllTablesFromDs(char* tdbName,bool tableDefinition, bool isDirect,char *username,char *password);
87 class BindBuffer
89 public:
90 void *csql;
91 void *targetdb;
92 DataType type;
93 int length;
94 BindBuffer(){ csql = NULL; targetdb = NULL; type = typeUnknown; length =0; }
95 ~BindBuffer() { ::free(csql); ::free(targetdb); }
97 class CacheTableInfo
99 public:
100 char tableName[IDENTIFIER_LENGTH];
101 char fieldName[IDENTIFIER_LENGTH];
102 char projFieldlist[IDENTIFIER_LENGTH];
103 char condition[IDENTIFIER_LENGTH];
104 char dsnName[IDENTIFIER_LENGTH];
106 //char dsnId[IDENTIFIER_LENGTH];
107 //char dsnPwd[IDENTIFIER_LENGTH];
109 void setTableName(char *tblName){strcpy(tableName,tblName);}
110 void setDsnName(char *dsnname) { strcpy(dsnName,dsnname); }
111 // void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
112 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
114 void setFieldName(char *fldName){strcpy(fieldName,fldName);}
115 void setProjFieldList(char *fieldlist){ strcpy(projFieldlist,fieldlist);}
116 void setCondition(char *cond){ strcpy(condition,cond);}
117 char *getTableName(){return tableName;}
118 char *getFieldName(){return fieldName;}
119 char *getCondition(){ return condition;}
120 char *getProjFieldList(){return projFieldlist;}
122 #endif