changes for open source mmdb build
[csql.git] / include / CacheTableLoader.h
blob07811f3179b280c414cfd84a697008b9acffd3e0
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 char *getConditionVal(char *condition);
79 void setParamValues(AbsSqlStatement *stmt, int parampos, DataType type, int length, char *value);
82 class BindBuffer
84 public:
85 void *csql;
86 void *targetdb;
87 DataType type;
88 int length;
89 BindBuffer(){ csql = NULL; targetdb = NULL; type = typeUnknown; length =0; }
90 ~BindBuffer() { ::free(csql); ::free(targetdb); }
92 class CacheTableInfo
94 public:
95 char tableName[IDENTIFIER_LENGTH];
96 char fieldName[IDENTIFIER_LENGTH];
97 char projFieldlist[IDENTIFIER_LENGTH];
98 char condition[IDENTIFIER_LENGTH];
99 char dsnName[IDENTIFIER_LENGTH];
101 //char dsnId[IDENTIFIER_LENGTH];
102 //char dsnPwd[IDENTIFIER_LENGTH];
104 void setTableName(char *tblName){strcpy(tableName,tblName);}
105 void setDsnName(char *dsnname) { strcpy(dsnName,dsnname); }
106 // void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
107 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
109 void setFieldName(char *fldName){strcpy(fieldName,fldName);}
110 void setProjFieldList(char *fieldlist){ strcpy(projFieldlist,fieldlist);}
111 void setCondition(char *cond){ strcpy(condition,cond);}
112 char *getTableName(){return tableName;}
113 char *getFieldName(){return fieldName;}
114 char *getCondition(){ return condition;}
115 char *getProjFieldList(){return projFieldlist;}
117 #endif