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 #include<CacheTableLoader.h>
18 DbRetVal
CacheTableLoader::addToCacheTableFile(bool isDirect
)
21 fp
= fopen(Conf::config
.getTableConfigFile(),"a");
23 printError(ErrSysInit
, "Invalid path/filename in TABLE_CONFIG_FILE.\nTable will not be"
24 "recovered in case of crash");
27 //TODO::if already table present in the file, it means that the
28 //table is replicated. in this case change mode from
29 //2 to 3 (repl to replcache)
30 if( strcmp(fieldName
,"")==0 ){ strcpy(fieldName
,"NULL"); }
33 if((strcmp(conditionVal
,"")!=0)&&(strcmp(fieldlistVal
,"")!=0))
35 fprintf(fp
,"%d:%s %s %s %s\n",6,tableName
,fieldName
,conditionVal
,fieldlistVal
);
37 else if((strcmp(conditionVal
,"")!=0)&&(strcmp(fieldlistVal
,"")==0))
39 strcpy(fieldlistVal
,"NULL");
40 fprintf(fp
,"%d:%s %s %s %s\n",6,tableName
,fieldName
,conditionVal
,fieldlistVal
);
42 else if((strcmp(conditionVal
,"")==0)&&(strcmp(fieldlistVal
,"")!=0))
44 strcpy(conditionVal
,"NULL");
45 fprintf(fp
,"%d:%s %s %s %s\n",6,tableName
,fieldName
,conditionVal
,fieldlistVal
);
49 strcpy(fieldlistVal
,"NULL");
50 strcpy(conditionVal
,"NULL");
51 fprintf(fp
,"%d:%s %s %s %s\n",5,tableName
,fieldName
,conditionVal
,fieldlistVal
);
56 if((strcmp(conditionVal
,"")!=0)&&(strcmp(fieldlistVal
,"")!=0))
58 fprintf(fp
,"%d:%s %s %s %s\n",2,tableName
,fieldName
,conditionVal
,fieldlistVal
);
60 else if((strcmp(conditionVal
,"")!=0)&&(strcmp(fieldlistVal
,"")==0))
62 strcpy(fieldlistVal
,"NULL");
63 fprintf(fp
,"%d:%s %s %s %s\n",2,tableName
,fieldName
,conditionVal
,fieldlistVal
);
65 else if((strcmp(conditionVal
,"")==0)&&(strcmp(fieldlistVal
,"")!=0))
67 strcpy(conditionVal
,"NULL");
68 fprintf(fp
,"%d:%s %s %s %s\n",2,tableName
,fieldName
,conditionVal
,fieldlistVal
);
72 strcpy(fieldlistVal
,"NULL");
73 strcpy(conditionVal
,"NULL");
74 fprintf(fp
,"%d:%s %s %s %s\n",1,tableName
,fieldName
,conditionVal
,fieldlistVal
);
82 DbRetVal
CacheTableLoader::removeFromCacheTableFile()
85 char tmpFileName
[MAX_FILE_PATH_LEN
];
86 sprintf(tmpFileName
, "%s.tmp", Conf::config
.getTableConfigFile());
87 tmpfp
= fopen(tmpFileName
,"w");
89 printError(ErrSysInit
, "Invalid path/filename in TABLE_CONFIG_FILE.\n");
92 fp
= fopen(Conf::config
.getTableConfigFile(),"r");
94 printError(ErrSysInit
, "csqltable.conf file does not exist");
97 char tablename
[IDENTIFIER_LENGTH
];
98 char fieldname
[IDENTIFIER_LENGTH
];
99 char condition
[IDENTIFIER_LENGTH
];
100 char field
[IDENTIFIER_LENGTH
];
104 fscanf(fp
, "%d:%s %s %s %s\n", &mode
, tablename
,fieldname
,condition
,field
);
105 if (strcmp (tablename
, tableName
) == 0) continue;
106 fprintf(tmpfp
, "%d:%s %s %s %s\n", mode
, tablename
,fieldname
,condition
,field
);
110 char sysCommand
[MAX_FILE_PATH_LEN
* 2];
111 sprintf(sysCommand
, "mv %s %s", tmpFileName
, Conf::config
.getTableConfigFile());
112 int ret
= system(sysCommand
);
115 printError(ErrSysInit
, "Check csqltable.conf file permission. unable to remove %s from file", tableName
);
121 // new function is added by: Jitendra
122 DbRetVal
CacheTableLoader :: isTablePresent()
127 rv
= conn
.open(userName
,password
);
128 if(rv
!=OK
) return ErrSysInit
;
129 // check for CACHE_TABLE variable
132 fp
= fopen(Conf :: config
.getTableConfigFile(),"r");
135 printError(ErrSysInit
, "cachetable.conf file does not exist");
140 char tablename
[IDENTIFIER_LENGTH
];
141 char condition
[IDENTIFIER_LENGTH
];
142 char fieldname
[IDENTIFIER_LENGTH
];
143 char field
[IDENTIFIER_LENGTH
];
148 tablename
[0] = '\0'; condition
[0] = '\0';
149 fscanf(fp
,"%d:%s %s %s %s\n",&mode
,tablename
,fieldname
,condition
,field
);
151 if(strcmp(tableName
,tablename
)==0)
163 DbRetVal
CacheTableLoader::load(bool tabDefinition
)
166 DbRetVal rv
= conn
.open(userName
, password
);
167 if (rv
!= OK
) return ErrSysInit
;
168 // check for CACHE_TABLE variable
171 DatabaseManager
*dbMgr
= (DatabaseManager
*) conn
.getDatabaseManager();
172 if (dbMgr
== NULL
) { printError(ErrSysInit
, "Auth failed\n"); return ErrSysInit
; }
173 if (tabDefinition
== false) {
174 Table
*tbl
= dbMgr
->openTable(tableName
);
179 if (tbl
->numTuples()) {
180 printError(ErrNotEmpty
, "The table '\%s\' is not empty", tableName
);
181 dbMgr
->closeTable(tbl
);
186 conn
.startTransaction();
187 rv
= load(dbMgr
, tabDefinition
);
193 DbRetVal
CacheTableLoader::load(DatabaseManager
*dbMgr
, bool tabDefinition
)
196 sprintf(dsn
, "DSN=%s;", Conf::config
.getDSN());
197 SQLCHAR outstr
[1024];
198 SQLSMALLINT outstrlen
;
204 retValue
= SQLAllocHandle (SQL_HANDLE_ENV
, SQL_NULL_HANDLE
, &henv
);
205 if (retValue
) {printError(ErrSysInit
, "Unable to allocate ODBC handle \n"); return ErrSysInit
; }
206 SQLSetEnvAttr(henv
, SQL_ATTR_ODBC_VERSION
, (void *) SQL_OV_ODBC3
, 0);
207 retValue
= SQLAllocHandle (SQL_HANDLE_DBC
, henv
, &hdbc
);
208 if (retValue
) {printError(ErrSysInit
, "Unable to allocate ODBC handle \n"); return ErrSysInit
; }
209 retValue
= SQLDriverConnect(hdbc
, NULL
, (SQLCHAR
*)dsn
, SQL_NTS
,
210 outstr
, sizeof(outstr
), &outstrlen
,
211 SQL_DRIVER_NOPROMPT
);
212 if (SQL_SUCCEEDED(retValue
)) {
213 printDebug(DM_Gateway
, "Connected to target database using dsn = %s\n", dsn
);
215 fprintf(stderr
, "Failed to connect to target database\n");
219 retValue
=SQLAllocHandle (SQL_HANDLE_STMT
, hdbc
, &hstmt
);
220 if (retValue
) {printError(ErrSysInit
, "Unable to allocate ODBC handle \n"); return ErrSysInit
; }
223 if(((strcmp(conditionVal
,"")==0) || (strcmp(conditionVal
,"NULL")==0)) && ((strcmp(fieldlistVal
,"")==0) || (strcmp(fieldlistVal
,"NULL")==0)))
225 sprintf(stmtBuf
, "SELECT * FROM %s;", tableName
);
227 else if(((strcmp(conditionVal
,"")!=0) || (strcmp(conditionVal
,"NULL")!=0)) && ((strcmp(fieldlistVal
,"")==0) || (strcmp(fieldlistVal
,"NULL")==0)))
229 sprintf(stmtBuf
,"SELECT * FROM %s where %s;",tableName
,conditionVal
);
232 else if(((strcmp(conditionVal
,"")==0) || (strcmp(conditionVal
,"NULL")==0)) && ((strcmp(fieldlistVal
,"")!=0) || (strcmp(fieldlistVal
,"NULL")!=0)))
234 sprintf(stmtBuf
,"SELECT %s FROM %s;",fieldlistVal
,tableName
);
237 sprintf(stmtBuf
,"SELECT %s FROM %s where %s;",fieldlistVal
,tableName
,conditionVal
);
239 retValue
= SQLPrepare (hstmt
, (unsigned char *) stmtBuf
, SQL_NTS
);
240 if (retValue
) {printError(ErrSysInit
, "Unable to Prepare ODBC statement \n"); return ErrSysInit
; }
244 retValue
= SQLNumResultCols (hstmt
, &totalFields
);
245 if (retValue
) {printError(ErrSysInit
, "Unable to retrieve ODBC total columns\n"); return ErrSysInit
; }
247 UCHAR colName
[IDENTIFIER_LENGTH
];
255 icol
= 1; colNameMax
= IDENTIFIER_LENGTH
;
256 char columnname
[IDENTIFIER_LENGTH
];
257 char indexname
[IDENTIFIER_LENGTH
];
258 short type
; short unique
;
260 retValue
=SQLAllocHandle (SQL_HANDLE_STMT
, hdbc
, &hstmtmeta
);
263 printError(ErrSysInit
, "Unable to allocate ODBC handle \n");
266 retValue
=SQLPrimaryKeys(hstmtmeta
, NULL
, SQL_NTS
, NULL
, SQL_NTS
, (SQLCHAR
*) tableName
, SQL_NTS
);
267 retValue
= SQLBindCol(hstmtmeta
, 4, SQL_C_CHAR
,columnname
, 129,NULL
);
268 HashIndexInitInfo
*inf
= new HashIndexInitInfo();
269 bool isPriIndex
=false;
270 char indname
[IDENTIFIER_LENGTH
];
271 if(SQLFetch( hstmtmeta
) == SQL_SUCCESS
)
273 inf
->list
.append(columnname
);
274 while( SQLFetch( hstmtmeta
) == SQL_SUCCESS
)
276 inf
->list
.append(columnname
);
278 inf
->indType
= hashIndex
;
279 inf
->bucketSize
= 10007;
280 inf
->isUnique
= true; inf
->isPrimary
= true;
281 strcpy(inf
->tableName
, tableName
);
282 strcpy(indexname
,"PRIMARY");
283 sprintf(indname
, "%s_%s", tableName
, indexname
);
287 bool iskeyfieldExist
=true;
288 if(isPriIndex
&& (strcmp(fieldlistVal
,"")!=0) && (strcmp(fieldlistVal
,"NULL")!=0))
290 inf
->list
.resetIter();
291 while ((name
=inf
->list
.nextFieldName())!=NULL
)
293 iskeyfieldExist
=isFieldExist(name
);
294 if(!iskeyfieldExist
) { break; }
296 }else if(!isPriIndex
){iskeyfieldExist
= false;}
297 if(((strcmp(fieldName
,"")!=0) && (strcmp(fieldName
,"NULL")!=0)) && !(isFieldExist(fieldName
)))
299 if(Conf::config
.useTwoWayCache() && (strcmp(fieldlistVal
,"")!=0) && (strcmp(fieldlistVal
,"NULL")!=0))
301 printError(ErrSysInit
, "Bidirectonal caching fail for no primary key in %s \n", tableName
);
306 if(!iskeyfieldExist
&& ((strcmp(fieldName
,"")==0) || (strcmp(fieldName
,"NULL")==0)))
308 if(Conf::config
.useTwoWayCache())
310 printError(ErrSysInit
, "Bidirectonal caching fail for no primary key in %s \n", tableName
);
315 bool isNullfld
=false;
316 while (icol
<= totalFields
) {
317 retValue
= SQLDescribeCol(hstmt
, icol
, colName
, colNameMax
,
318 &nameLength
, &colType
, &colLength
,
320 if (retValue
) {printError(ErrSysInit
, "Unable to retrieve ODBC column info\n"); return ErrSysInit
; }
322 printDebug(DM_Gateway
, "Describe Column %s %d %d \n", colName
, colType
, colLength
);
324 if(strcmp((char*)colName
,fieldName
)== 0)
331 inf
->list
.resetIter();
332 while ((name
=inf
->list
.nextFieldName())!=NULL
)
334 if(0==strcmp((char*)colName
,name
))
336 tabDef
.addField((char*)colName
, AllDataType::convertFromSQLType(colType
), colLength
+1, NULL
, true);
343 tabDef
.addField((char*)colName
, AllDataType::convertFromSQLType(colType
), colLength
+1);
345 tabDef
.addField((char*)colName
, AllDataType::convertFromSQLType(colType
), colLength
+1, NULL
, true);
351 tabDef
.addField((char*)colName
, AllDataType::convertFromSQLType(colType
), colLength
+1, NULL
, true);
353 if(((strcmp(fieldName
,"")!=0) && (strcmp(fieldName
,"NULL")!=0))&& !isKeyFld
)
355 printError(ErrSysInit
, "Unable to cache Table for %s with key field %s\n", tableName
,fieldName
);
359 rv
= dbMgr
->createTable(tableName
, tabDef
);
362 printError(ErrSysInit
, "Table creation failed in csql for %s\n", tableName
);
367 rv
= dbMgr
->createIndex(indname
, inf
);
370 printError(ErrSysInit
, "Index creation failed in csql for %s\n", tableName
);
377 if(Conf::config
.useTwoWayCache() && iskeyfieldExist
)
379 printError(ErrSysInit
, "Bidirectonal caching fail for no primary key in %s \n", tableName
);
383 retValue
= SQLCloseCursor(hstmtmeta
);
385 retValue
= SQLStatistics(hstmtmeta
, NULL
, 0, NULL
, SQL_NTS
,
386 (SQLCHAR
*) tableName
, SQL_NTS
, SQL_INDEX_ALL
, SQL_QUICK
);
387 retValue
= SQLBindCol(hstmtmeta
, 4, SQL_C_SHORT
,
389 retValue
= SQLBindCol(hstmtmeta
, 6, SQL_C_CHAR
,
390 indexname
, 129, NULL
);
391 retValue
= SQLBindCol(hstmtmeta
, 7, SQL_C_SHORT
,
393 retValue
= SQLBindCol(hstmtmeta
, 9, SQL_C_CHAR
,
394 columnname
, 129,NULL
);
395 while ((retValue
= SQLFetch(hstmtmeta
)) == SQL_SUCCESS
)
396 { //if (type != SQL_TABLE_STAT)
398 printDebug(DM_Gateway
, "Column: %-18s Index Name: %-18s unique:%hd type:%hd\n",
399 columnname
, indexname
, unique
, type
);
401 if(0 == strcmp(columnname
,fieldName
)){isKeyFld
=true;}
402 bool isPrimary
=false;
403 inf
->list
.resetIter();
404 while ((name
=inf
->list
.nextFieldName())!=NULL
)
406 if(0==strcmp(columnname
,name
))
412 if(isPrimary
){continue;}
414 HashIndexInitInfo
*info
= new HashIndexInitInfo();
415 info
->indType
= hashIndex
;
416 info
->bucketSize
= 10007;
417 info
->list
.append(columnname
);
418 if (!unique
) {info
->isUnique
= true; info
->isPrimary
= false;}
419 strcpy(info
->tableName
, tableName
);
421 sprintf(indname
, "%s_%s", tableName
, indexname
);
422 rv
= dbMgr
->createIndex(indname
, info
);
425 printError(ErrSysInit
, "Index creation failed in csql for %s\n", tableName
);
431 printError(ErrSysInit
,"CSQL does not support this index type\n");
435 }// while meta data fetch for index creation
436 SQLCloseCursor (hstmtmeta
);
437 SQLFreeHandle (SQL_HANDLE_STMT
, hstmtmeta
);
438 if( !isKeyFld
&& ((strcmp(fieldName
,"")!=0) && (strcmp(fieldName
,"NULL")!=0)))
440 printError(ErrSysInit
, "Unable to cache Table for %s with key field %s\n", tableName
,fieldName
);
441 dbMgr
->dropTable(tableName
);
446 Table
*table
= dbMgr
->openTable(tableName
);
448 printError(ErrSysInit
,"unable to open table %s\n", tableName
);
449 dbMgr
->closeTable(table
);
450 if (tabDefinition
) dbMgr
->dropTable(tableName
);
454 table
->setUndoLogging(false);
455 //rv = table->lock(false); //no need to release this lock as it is upgrade from S to X
458 dbMgr
->closeTable(table
);
459 if (tabDefinition
) dbMgr
->dropTable(tableName
);
463 List fNameList
= table
->getFieldNameList();
464 ListIterator fNameIter
= fNameList
.getIterator();
465 FieldInfo
*info
= new FieldInfo();
466 int fcount
=1; void *valBuf
; int fieldsize
=0;
467 Identifier
*elem
= NULL
;
471 SQLINTEGER len
[IDENTIFIER_LENGTH
];
472 while (fNameIter
.hasElement()) {
473 elem
= (Identifier
*) fNameIter
.nextElement();
474 table
->getFieldInfo((const char*)elem
->name
, info
);
475 valBuf
= AllDataType::alloc(info
->type
, info
->length
);
476 table
->bindFld(elem
->name
, valBuf
);
481 fieldsize
= info
->length
;
484 bBuf
= new BindBuffer();
486 bBuf
->type
= typeDate
;
487 fieldsize
= sizeof(DATE_STRUCT
);
488 bBuf
->targetdb
= malloc(fieldsize
);
489 valBuf
= bBuf
->targetdb
;
490 valBufList
.append(bBuf
);
493 bBuf
= new BindBuffer();
495 bBuf
->type
= typeTime
;
496 fieldsize
= sizeof(TIME_STRUCT
);
497 bBuf
->targetdb
= malloc(fieldsize
);
498 valBuf
= bBuf
->targetdb
;
499 valBufList
.append(bBuf
);
502 bBuf
= new BindBuffer();
504 bBuf
->type
= typeTimeStamp
;
505 fieldsize
= sizeof(TIMESTAMP_STRUCT
);
506 bBuf
->targetdb
= malloc(fieldsize
);
507 valBuf
= bBuf
->targetdb
;
508 valBufList
.append(bBuf
);
511 retValue
= SQLBindCol (hstmt
, fcount
, AllDataType::convertToSQLType(info
->type
),
512 valBuf
, fieldsize
, &len
[fcount
]);
514 if (retValue
) {printError(ErrSysInit
, "Unable to bind columns in ODBC\n"); return ErrSysInit
; }
517 retValue
= SQLExecute (hstmt
);
518 if (retValue
) {printError(ErrSysInit
, "Unable to execute ODBC statement\n"); return ErrSysInit
; }
522 retValue
= SQLFetch (hstmt
);
524 ListIterator bindIter
= valBufList
.getIterator();
525 while (bindIter
.hasElement()) {
526 bBuf
= (BindBuffer
*) bindIter
.nextElement();
527 switch (bBuf
->type
) {
529 Date
*dtCSQL
= (Date
*) bBuf
->csql
;
530 DATE_STRUCT
*dtTarget
= (DATE_STRUCT
*) bBuf
->targetdb
;
531 dtCSQL
->set(dtTarget
->year
,dtTarget
->month
,dtTarget
->day
);
535 Time
*dtCSQL
= (Time
*) bBuf
->csql
;
536 TIME_STRUCT
*dtTarget
= (TIME_STRUCT
*) bBuf
->targetdb
;
537 dtCSQL
->set(dtTarget
->hour
,dtTarget
->minute
,dtTarget
->second
);
540 case typeTimeStamp
: {
541 TimeStamp
*dtCSQL
= (TimeStamp
*) bBuf
->csql
;
542 TIMESTAMP_STRUCT
*dtTarget
= (TIMESTAMP_STRUCT
*) bBuf
->targetdb
;
543 dtCSQL
->setDate(dtTarget
->year
,dtTarget
->month
,dtTarget
->day
);
544 dtCSQL
->setTime(dtTarget
->hour
,dtTarget
->minute
,dtTarget
->second
, dtTarget
->fraction
);
550 table
->resetNullinfo();
551 while(fldpos
< fcount
-1)
553 if(len
[++fldpos
] == SQL_NULL_DATA
){
554 table
->markFldNull(fldpos
);
558 table
->insertTuple();
560 //TODO::leak:: valBufList and its targetdb buffer
562 dbMgr
->closeTable(table
);
563 SQLCloseCursor (hstmt
);
564 SQLFreeHandle (SQL_HANDLE_STMT
, hstmt
);
565 SQLDisconnect (hdbc
);
566 SQLFreeHandle (SQL_HANDLE_DBC
, hdbc
);
567 SQLFreeHandle (SQL_HANDLE_ENV
, henv
);
571 DbRetVal
CacheTableLoader::reload()
573 DbRetVal rv
= unload(false);
574 if (rv
!= OK
) return rv
;
579 DbRetVal
CacheTableLoader::unload(bool tabDefinition
)
582 DbRetVal rv
= conn
.open(userName
, password
);
583 if (rv
!= OK
) return ErrSysInit
;
585 if (isTableCached() != OK
) {
586 printError(ErrNotCached
, "The table \'%s\' is not cached", tableName
);
589 DatabaseManager
*dbMgr
= (DatabaseManager
*) conn
.getDatabaseManager();
590 if (dbMgr
== NULL
) { printError(ErrSysInit
, "Auth failed\n"); return ErrSysInit
; }
593 Table
*table
= dbMgr
->openTable(tableName
);
594 if (table
== NULL
) { conn
.close(); return ErrBadCall
; }
595 rv
= conn
.startTransaction();
596 if (rv
!= OK
) { dbMgr
->closeTable(table
); conn
.close(); return ErrBadCall
; }
599 dbMgr
->closeTable(table
);
603 rv
= dbMgr
->dropTable(tableName
);
610 DbRetVal
CacheTableLoader::refresh()
615 DbRetVal
CacheTableLoader::recoverAllCachedTables()
619 DbRetVal rv
= conn
.open(userName
, password
);
620 if(rv
!=OK
) return ErrSysInit
;
622 //Note: if connection is not open, configuration veriables may be incorrect
624 fp
= fopen(Conf::config
.getTableConfigFile(),"r");
626 printError(ErrSysInit
, "cachetable.conf file does not exist");
630 //TODO::take exclusive lock on database
631 char tablename
[IDENTIFIER_LENGTH
];
632 char fieldname
[IDENTIFIER_LENGTH
];
633 char condition
[IDENTIFIER_LENGTH
];
634 char field
[IDENTIFIER_LENGTH
];
639 fscanf(fp
, "%d:%s %s %s %s\n", &mode
, tablename
,fieldname
,condition
,field
);
640 //if (mode ==2 ) //just replicated table and not cached
642 printDebug(DM_Gateway
, "Recovering Table from target db: %s\n", tablename
);
643 setCondition(condition
);
645 setFieldName(fieldname
);
646 setFieldListVal(field
);
647 printf("Recovering table %s %s %s\n", tablename
,condition
,field
);
649 if (rv
!= OK
) return rv
;
655 DbRetVal
CacheTableLoader::isTableCached()
658 char tmpFileName
[MAX_FILE_PATH_LEN
];
659 fp
= fopen(Conf::config
.getTableConfigFile(),"r");
661 printError(ErrSysInit
, "csqltable.conf file does not exist");
664 char tablename
[IDENTIFIER_LENGTH
];
665 char fieldname
[IDENTIFIER_LENGTH
];
666 char condition
[IDENTIFIER_LENGTH
];
667 char field
[IDENTIFIER_LENGTH
];
671 fscanf(fp
, "%d:%s %s %s %s\n", &mode
, tablename
,fieldname
,condition
,field
);
672 if (strcmp (tablename
, tableName
) == 0) {
681 int CacheTableLoader::getTableMode(char *tabname
)
684 fp
= fopen(Conf::config
.getTableConfigFile(),"r");
686 printError(ErrSysInit
, "cachetable.conf file does not exist");
690 char tablename
[IDENTIFIER_LENGTH
];
691 char fieldname
[IDENTIFIER_LENGTH
];
692 char condition
[IDENTIFIER_LENGTH
];
693 char field
[IDENTIFIER_LENGTH
];
697 fscanf(fp
,"%d:%s %s %s %s\n",&mode
,tablename
,fieldname
,fieldname
,condition
);
698 if(0==strcmp(tabname
,tablename
)){
708 bool CacheTableLoader::isFieldExist(char *fieldname
)
710 char tmpfieldname
[IDENTIFIER_LENGTH
];
712 while(fieldlistVal
[j
]!=0)
714 if(fieldlistVal
[j
] != ',')
715 tmpfieldname
[i
++]=fieldlistVal
[j
++];
718 tmpfieldname
[i
]='\0';
719 if(strcmp(fieldname
,tmpfieldname
)==0)
724 tmpfieldname
[i
]='\0';
725 if(strcmp(fieldname
,tmpfieldname
)==0)