adding union patch diff file
[csql.git] / include / CacheTableLoader.h
blobf3738d47b84f3d005a0fb588656225ba7f4f3b97
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 fieldNameList;
28 ~CacheIndexInfo() { fieldNameList.removeAll(); }
31 class CacheTableLoader
33 char tableName[IDENTIFIER_LENGTH];
34 char fieldName[IDENTIFIER_LENGTH];
35 char userName[IDENTIFIER_LENGTH];
36 char password[IDENTIFIER_LENGTH];
37 char conditionVal[IDENTIFIER_LENGTH]; //added newly
38 char fieldlistVal[IDENTIFIER_LENGTH];
39 char dsnName[IDENTIFIER_LENGTH];
40 bool resolveForDSN(char *dsn, TDBInfo &tdbName, DbRetVal &rv);
41 void generateCacheTableStatement(char *stmtBuf);
42 bool prepareCreateIndexStatement(SQLHSTMT hstmtmeta, char *crtIdxStmt, TDBInfo tdbName, HashIndexInitInfo *inf);
43 DbRetVal prepareCreateTableStatement(char *crtTblStmt, SQLHSTMT hstmt, HashIndexInitInfo *inf, int totalFields, TDBInfo tdbName, bool &isKeyFld);
44 void prepareInsertStatement(AbsSqlStatement *stmt, List *fNameList, char *insStmt);
45 bool shouldForce;
46 public:
47 CacheTableLoader()
49 strcpy(tableName,"");
50 strcpy(conditionVal,"");
51 strcpy(fieldName,"");
52 strcpy(fieldlistVal,"");
53 strcpy(dsnName,"");
54 //strcpy(dsnId,"");
55 //strcpy(dsnPwd,"");
56 shouldForce = false;
58 DbRetVal createIndex(SQLHSTMT hstmtmeta, char *tableName, HashIndexInitInfo *inf,AbsSqlStatement *stmt,bool isPKFieldSpecified);
59 void setForceFlag(bool flag){ shouldForce = flag;}
60 void setConnParam(char *user, char *pass){ strcpy(userName, user); strcpy(password, pass); }
61 void setTable(char *tablename) { strcpy(tableName,tablename); }
62 void setCondition(char *condition){strcpy(conditionVal,condition);} //new one
63 void setDsnName(char *dname) {strcpy(dsnName,dname);}
65 //void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
66 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
67 void setFieldName(char *fldname){ strcpy(fieldName,fldname);}
68 DbRetVal addToCacheTableFile(bool isDirect);
69 void setFieldListVal(char *field) {strcpy(fieldlistVal,field);}
71 DbRetVal addToCacheTableFile();
72 DbRetVal removeFromCacheTableFile();
73 DbRetVal load(bool tabDef=true);
74 DbRetVal reload();
75 DbRetVal unload(bool tabDefinition = true);
76 DbRetVal refresh();
77 DbRetVal recoverAllCachedTables();
78 DbRetVal load(AbsSqlConnection *conn, AbsSqlStatement *stmt, bool tabDef);
79 DbRetVal isTablePresent();// new one by :Jitendra
80 DbRetVal CacheInfo(bool isTabPresent);
81 DbRetVal tablesOnDsn();
82 char *getConditionVal(char *condition);
83 DbRetVal checkingSchema(SQLHDBC hdbc,SQLHSTMT hstmt,AbsSqlConnection *conn, AbsSqlStatement *stmt,TDBInfo tdbName);
84 DbRetVal cacheAllTablesFromDs(char* tdbName,bool tableDefinition, bool isDirect,char *username,char *password);
89 class BindBuffer
91 public:
92 void *csql;
93 void *targetdb;
94 SQLLEN *nullData;
95 DataType type;
96 int length;
97 BindBuffer()
99 csql = NULL; targetdb = NULL; type = typeUnknown;
100 length =0; nullData = NULL;
102 ~BindBuffer() { ::free(csql); ::free(targetdb); ::free(nullData); }
104 class CacheTableInfo
106 public:
107 char tableName[IDENTIFIER_LENGTH];
108 char fieldName[IDENTIFIER_LENGTH];
109 char projFieldlist[IDENTIFIER_LENGTH];
110 char condition[IDENTIFIER_LENGTH];
111 char dsnName[IDENTIFIER_LENGTH];
112 char pkField[IDENTIFIER_LENGTH];
114 //char dsnId[IDENTIFIER_LENGTH];
115 //char dsnPwd[IDENTIFIER_LENGTH];
117 void setTableName(char *tblName){strcpy(tableName,tblName);}
118 void setDsnName(char *dsnname) { strcpy(dsnName,dsnname); }
119 // void setDsnId(char *dsnid) { strcpy(dsnId,dsnid); }
120 //void setDsnPwd(char *dsnpwd){ strcpy(dsnPwd,dsnpwd);}
122 void setFieldName(char *fldName){strcpy(fieldName,fldName);}
123 void setProjFieldList(char *fieldlist){ strcpy(projFieldlist,fieldlist);}
124 void setCondition(char *cond){ strcpy(condition,cond);}
125 void setPKField(char *pkfield) { strcpy(pkField, pkfield); }
126 char *getTableName(){return tableName;}
127 char *getFieldName(){return fieldName;}
128 char *getPKFieldName(){return pkField;}
129 char *getCondition(){ return condition;}
130 char *getProjFieldList(){return projFieldlist;}
132 #endif