1c1 < /******************************************************************************/ --- > /************************************************************************/ 5c5,16 < /******************************************************************************/ --- > /************************************************************************/ > /* > * $Log: pr_log.c,v $ > * Revision 1.1.2.26 2005/02/25 00:34:13 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.25 2004/11/29 20:10:20 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ 14a26 > /* hcg_logfile[NAMELENGTH] defined where #ifdef MAIN (in bde/src/fileio.cc)*/ 16,17c28 < < /******************************************************************************/ --- > /**********************************************************************/ 19c30 < /******************************************************************************/ --- > /**********************************************************************/ 24c35,38 < strcpy(); --- > char *strcpy( > char *s1, > const char *s2); > /* strcpy();*/ 41c55 < extern void pr_del(int); /* REQUIRES XXcurr ptr */ --- > extern void pr_del(int); /* arg1=XX.idx; REQUIRES valid XXcurr ptr */ 44,45c58,60 < #ifdef BDELOG < extern "C" int replay_log(void); --- > /* #ifdef BDELOG */ > #ifdef GENLOG > extern /*"C"*/ int replay_log(void); 64c79 < char viewname[NAMELENGTH]; --- > char viewname[NAMELENGTH]; // in limits.h? -see pr_load.c 86,89d100 < int dbg = 1; < #define dprintf(string) if (dbg) printf(string); < #define dprintf1arg(string, arg1) if (dbg) printf(string, arg1); < #define dprintf2args(string, arg1, arg2) if (dbg) printf(string, arg1, arg2); 91c102 < /******************************************************************************/ --- > /************************************************************************/ 93c104 < /******************************************************************************/ --- > /************************************************************************/ 185c196 < --- > EP; 277c288 < } --- > } /* end mysleep */ 353c364 < } --- > } /* end get_delta_tee */ 398c409 < if (hcg_log == 1) --- > if (hcg_log) 456c467 < --- > EP; 458d468 < 467c477 < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 473c483,484 < /* check that logging is off - if not, return without starting log*/ --- > /* pre-condition: logging is off - recursion not allowed */ > assert(!hcg_log); 475c486 < if (hcg_log != 0 ) --- > if (hcg_replay) 477,483c488 < if (hcg_log == 1 ) < { < printf("Error: pr_startlog called when logging was not off.\n"); < return (-3); < } < else if ( hcg_log == 2) < printf("Error: pr_startlog called when logging was not off.\n"); --- > printf("WARNING:: pr_startlog called during replay .\n"); 484a490 > 492c498 < /* set global hcg_logfile to file name of log file (w/out extention) */ --- > /* set global hcg_logfile to file name of log file (w/out extension) */ 494,497c500,503 < (i>=0) && (file_name[i]!= '.'); < i--); < < if (i<0) /* no extention */ --- > ((i>=0) && (file_name[i]!= '.')); /* no period found yet */ > (i--)); > /* (i = namelength before type extension, i == -1 if no type ext.) */ > if (i<0) /* no extension */ 499,500c505 < < else /* remove extention */ --- > else /* remove extension */ 516c521 < --- > /* This will be a checkpoint for initialization during replay. */ 518c523 < pr_dump (viewname, logfileDB1_name, FALSE, "w" ); --- > DP; pr_dump (viewname, logfileDB1_name, FALSE, "w" ); 521c526 < --- > /* hcg_replay is either on or off. - RJL 040712 */ 526c531 < logstr("SR\n"); --- > logstr("SR\n"); // logstr is conditional on hcg_replay */ 540,541c545,549 < /* It optionally dumps a current copy of the database and closes */ < /* the logfile */ --- > /* If (dump_flag), dumps a copy of the database */ > /* to logfileDB2_name and closes the logfile */ > /* [RJL 040615] If (hcg_log==1) and viewname is valid, */ > /* sets hcg_log = 0, closes hcg_logfileptr and returns 0; */ > /* else is a no-op (returning -1 if (!hcg_log), -2 if viewname invalid) */ 555c563 < --- > EP; 564c572 < /* check that viewname is valid - if not, return without starting log*/ --- > /* check that viewname is valid - if not, return without stopping log*/ 566c574 < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 568c576 < printf("Error: view %s passed to pr_startlog is not defined.\n",viewname); --- > printf("Error: view %s passed to pr_stopog is not defined.\n",viewname); 576c584 < logwait(); --- > logwait(); /* conditional on hcg_replay */ 580,584c588,589 < logstr("SP\n"); < < /* Terminate logging by setting global hcg_log = 0 */ < < hcg_log =0; --- > logstr("SP\n"); /* conditional on hcg_replay */ > hcg_log = 0; /* Terminate logging */ 591c596 < pr_dump (viewname, logfileDB2_name, FALSE, "w" ); --- > DP; pr_dump (viewname, logfileDB2_name, FALSE, "w" ); 600c605,606 < /* This function is used to parse the data file(logdata.txt)*/ --- > /* This function is used to parse the data in logdata.txt */ > /* (to which pr_log appended all files in pr_init's arg2) */ 602,610c608,623 < /* original data files. It returns a string list with */ < /* the names of the new files. The new file names are */ < /* separated by spaces. It returns a value to indicate */ < /* success or failure. */ < /* */ < /* Arguments: newlist - a list of files separated by commas */ < /* */ < /* Preconditions: */ < /* newlist must be a character string of size BUFSIZE */ --- > /* original data files. It initializes char* newlist with */ > /* new temp* filenames separated by spaces. These files */ > /* will be read and deleted before replaying the logfile. */ > /* The return value indicates success=0, or failure <0. */ > /* */ > /* Arguments: newlist - updated list of temp* filenames. */ > /* */ > /* Preconditions: Added by RJL 030809: */ > /* File logdata.txt must exist with data TBscanned */ > /* Datafile lines: field 1 cannot be "LogDataFile " */ > /* newlist must not exceed BUFSIZE bytes in length */ > /* filenames must not exceed NAMELENGTH bytes */ > /* (BUFSIZE=256, NAMELENGTH=30 in bde's schema.h) */ > /* (FILENAME_MAX and PATH_MAX=255 in limits.h) */ > /* (Non-local file names cannot be prefixed by 'temp' */ > /* until path prefixes are deleted - RJL 030810.) */ 612,613c625,626 < /* returns: 0 - success */ < /* <0 - failure */ --- > /* returns: 0 - success (newlist has tempfnames) */ > /* <0 - failure (newlist is null) */ 619c632,633 < char datafile[NAMELENGTH],token[BUFSIZE],tempfname[NAMELENGTH],tempnewlist[BUFSIZE]; --- > char datafile[NAMELENGTH],token[BUFSIZE]; > char tempfname[NAMELENGTH],tempnewlist[BUFSIZE]; 622c636,637 < --- > EP; > newlist[0] = '\0'; 625,627c640,643 < if ((data_fp = fopen(datafile, "r")) ==NULL) < return(-3); < --- > if ((data_fp = fopen(datafile, "r")) ==NULL) { > printf("Failed to open file logdata.txt\n"); > return(-3); //newlist[0] = '\0'; > } 629,630c645,647 < hcg_read_next(); /* read first line of data file */ < idx = 0; --- > hcg_read_next(); /* read first line to hcg_buffer[BUFSIZE] */ > assert(strlen(hcg_buffer) <= BUFSIZE); /* else buffer overflow */ > idx = 0; /* running index in line buffer */ 633,634c650,651 < /* invalid file format */ < return(-5); --- > printf("File logdata.txt: Invalid format \n"); > return(-5); //newlist[0] = '\0'; 635a653 > 641,642c659,662 < if ((temp_fp = fopen(tempfname, "w")) ==NULL) < return(-3); --- > if ((temp_fp = fopen(tempfname, "w")) == NULL) { > printf("fopen(%s, \"w\" failed \n", tempfname); > return(-3); /* fail to open file */ > } 648a669 > 652a674 > assert(strlen(hcg_buffer) <= BUFSIZE); /* else buffer overflow */ 655c677 < } /* end while !feof loop */ --- > } /* end loop to copy lines until next "LogDataFile" token */ 660c682,683 < strcpy(newlist,tempnewlist); --- > assert(strlen(tempnewlist) <= BUFSIZE); > strcpy(newlist,tempnewlist); // non-empty list of fnames 662c685 < } --- > } /* end log_parselogdata */ 670,671c693 < /* Arguments: filelist - a list of files separated by */ < /* commas. */ --- > /* Arguments: filelist - list of files separated by commas */ 680c702 < dprintf1arg("Unlinked %s.\n",token); --- > dprints("Unlinked %s.\n",token); 687a710 > /* log_do_ SHOULD be renamed log_replay_ etc.-RJL 031019 */ 719c742 < if (!find_tbl_idx(tablename)) --- > if (!find_tbl_idx(tablename)) /* updates hcg_tbl_idx */ 727c750,751 < tbl_encoding = encoding(hcg_table_seq_list[hcg_tbl_idx].ttabbrev); /* global hcg_tbl_idx is set by find_tbl_idx */ --- > tbl_encoding = encoding(hcg_table_seq_list[hcg_tbl_idx].ttabbrev); > /* global hcg_tbl_idx is set by find_tbl_idx */ 783c807,808 < fprintf(stderr,"%s: %d: log_do_add: pr_create failed\n", __FILE__, __LINE__); --- > fprintf(stderr, "%s: %d: log_do_add: pr_create failed\n", > __FILE__, __LINE__); 1025c1050 < } --- > } /* end convert2temp */ 1028c1053 < /* Function: log_do_delete */ --- > /* Function: log_do_delete (log_replay_delete - RJL) */ 1033a1059,1063 > /* RJL note 031021: int find_tbl_idx puts a table type code in tbl_idx. > * and returns 0 or 1; pr_delete(XX) really deletes a row of the table 'type' > * with integer code XX##_idx. > * It works via this macro call: #define pr_delete(tbl) pr_del(tbl##_idx) > */ 1036c1066 < long unsigned temp_id; --- > 1037a1068 > int isValidTbl; 1039c1070,1075 < find_tbl_idx(pkeychar); --- > isValidTbl = find_tbl_idx(pkeychar); > if (!isValidTbl) { > fprintf(stdout, "find_tbl_idx fails to find pkey %s: DL cmd ignored.\n", pkeychar); > return; > } > /* else (find_tbl_idx() correctly updated hcg_tbl_idx) */ 1042c1078 < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > dprints("Found DL (delete-row) cmd. with pkey %s.\n", pkeychar); 1044,1045c1080,1081 < switch(tbl_encoding) { < --- > switch(tbl_encoding) > { 1127,1128c1163,1164 < } /* end if decode */ < } --- > } /* end if encode */ > } /* end log_do_delete */ 1146a1183 > int isValidTbl; 1149,1152c1186,1197 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s ; SET_INT cmd. ignored during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_int ignored: : failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n", pkeychar); 1159,1160c1204,1205 < printf("log_do_set_int %s not found.\n", pkeychar); < else{ --- > printf("log_do_set_int pkey %s not found.\n", pkeychar); > else{ /* no int fields */ 1168c1213 < else{ --- > else{ /* no int fields */ 1189a1235 > /* POSITION and SHAPE are floats */ 1263,1265c1309,1315 < } /* end switch */ < } /* end if decode */ < } --- > default: > assert(hcg_k = NULL); /* print error and exit */ > break; > > }; /* end switch */ > return; > } /* end log_do_set_int */ 1280c1330,1332 < void log_do_set_flt(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const float newval) --- > > void log_do_set_flt(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const float newval) 1283a1336 > int isValidTbl; 1286,1289c1339,1350 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s arg. of SET_FLT cmd. during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_int: failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n",pkeychar); 1442,1443c1503 < } /* end if decode */ < } --- > } /* end log_do_set_flt */ 1458c1518,1528 < void log_do_set_key(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const char newval[HCG_KEY_SIZE+1]) --- > /* THIS DOESN'T MAKE SENSE: 'encode(fieldname,&new_key)'; - RJL 040614 */ > /* fieldname matches a pfkey fieldname in a TA-child-row of a TT-row for hcg_tbl_idx.*/ > /* it is not a pkey itself and cannot be encoded. */ > /* Updating a pkey is a no-no: pkey is a unique immutable identifier. */ > /* Updating an fkey is possible but problematic - chain pointers must track the fkey. */ > /* Such tracking is only possible by unlink and relink macro calls (missing below) */ > /* *************************************************************/ > /* TBD: reject action for pkeys (fieldname[0-1] == pkeychar[0-1]) - RJL 040621 */ > /* #if 0 at line 1559 to EOF */ > void log_do_set_key(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const char newval[HCG_KEY_SIZE+1]) 1462,1463c1532,1534 < hcg_key new_key; < --- > int isValidTbl; > char ttabrv[HCG_ABBR_SIZE+1]; > // hcg_key new_key; 1465,1469c1536,1562 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); < if(encode(fieldname,&new_key) ==1) --- > isValidTbl = find_tbl_idx(pkey); > > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s: SET_KEY cmd. ignored during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_key: failed to encode pkey %s\n", pkey); > return; > } > /* TBD: prevent pkey pdate; allow fkey update only after adding unlink and relink calls */ > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprintss("Found SET_KEY for row pkey %s, pfkeyname %s.\n", pkeychar, fieldname); > /* if(encode(fieldname,&new_key) ==1) */ > /* ERROR ABOVE: newval is the new encoded value for some XXid tbl-row; */ > /* so (if legal), could pr_find XXcurr and update the pkey there. */ > /* newval is an ASCI pfkey; fieldname is its name XXid; */ > > strncpy(ttabrv, fieldname, HCG_ABBR_SIZE); /* ttabrv is problematic as pr_find arg1? */ > ttabrv[HCG_ABBR_SIZE] = '\0'; > /* use var_find_tbl_idx ? - RJL 040614 */ > /* requires further discrimination: (switch(ttyp or tbl_idx?) */ > /* if (pr_find( ttabrv, fieldname, newval)) */ > /* disallow pkey changes; */ > /* fkey changes OK iff unlink/link for referential integrity */ > /* and unlink and relink chain pointers as well - RJL 040614 */ 1471c1564 < dprintf1arg("Found DL with key %s.\n",fieldname); --- > dprints(" SET_KEY with pfkey %s ignored.\n",fieldname); 1472a1566,1571 > fprintf(stdout, "pkey update is illegal; fkey update is not supported - SET_KEY ignored\n"); > } > return; > /* returns above bypass following code for now - RJL 040814 */ > /* per-case, could reject action if tabletype = first 2 bytes of pfkeyname? */ > #if 0 1475c1574,1575 < case 0: /* FO table */ --- > case 0: /* FO table - no fkeys */ > /* e.g.: if strcmp(substr(fieldname,0,2), ttabrv) ==0){ */ 1482a1583 > /* } //end if strcmp */ 1505c1606 < case 3: /* HN table */ --- > case 3: /* HN table - one HGid fkey */ 1514a1616 > 1600,1602c1702,1703 < } /* end if decode of fieldname */ < } /* end if decode of pkey */ < } --- > #endif > } /* end log_do_set_key */ 1617c1718,1719 < void log_do_set_str(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const char newval[BUFSIZE+1]) --- > void log_do_set_str(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const char newval[BUFSIZE+1]) 1620a1723 > int isValidTbl; 1623,1626c1726,1737 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s arg. of SET_STR cmd. during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_str: failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n",pkeychar); 1775,1776c1886 < } /* end if decode */ < } --- > } /* end log_do_set_str */ 1784a1895 > /* This could be an STL map function if available in 'C". */ 1786c1897 < replayCode encode_token( char *token ) --- > replayCode encode_token( char *token ) /* convert token to command */ 1788a1900,1901 > EP; //assert(tokenlength == 2 || tokenlength == 10);//FAILED 040722.1630 > // failed 040903: called with legal pkey as token and DBrow content 1793a1907,1910 > else { > fprintf(stderr, "Illegal 10-byte commanda\"%s\", ignored\n", token); > return -1; > } 1803a1921,1923 > else { > fprintf(stderr, "Illegal 2-byte commanda\"%s\", ignored\n", token); > return -1; 1805c1925,1926 < else --- > } > else if (tokenlength == HCG_KEY_SIZE) 1806a1928,1931 > else { > dprintsd("Illegal token %s length=%d\n", token, tokenlength); > return -1; /* can't reach here - else 'reach end of non-void fcn' */ > } 1815a1941,1944 > /* It is application-independent and completely chgen-produced. */ > /* TBD? Update MVstate/RFLAG+ to trigger updatedisplaylist and ReDraw? */ > /* RJL 040904: this fails on a pkey token1 in legal DB record */ > /* WARNING: viewfile and viewname may depend on external replay sources? */ 1827a1957 > char viewfile[FILENAME_MAX]; 1836c1966 < dprintf2args("Token =%s, Command = %d\n", token, command); --- > DP;dprintsd("Token =%s, Command = %d\n", token, command); 1844c1974 < dprintf1arg("Found WA with total milliseconds %d.\n",totMsec); --- > dprintd("Found WA with total milliseconds %d.\n", totMsec); 1850a1981 > if (strlen(temp_newkey) == 0) break; // Null pkey -ignore 1888c2019 < hcg_parse(hcg_buffer,viewname,&idx); --- > hcg_parse(hcg_buffer,viewfile,&idx); 1892,1893c2023,2024 < dprintf2args("Found IN with viewname %s, datalist=%s.\n",viewname,temp); < pr_init(viewname,tempdatalist); --- > dprintss("Found IN with viewfile %s, datalist=%s.\n",viewfile,temp); > DP; pr_init(viewfile,tempdatalist); 1901,1902c2032,2033 < dprintf2args("Found LD: viewname:%s,datafile:%s.\n",logviewname, newdatafile); < pr_load(logviewname,newdatafile); --- > dprintss("Found LD: viewname:%s,datafile:%s.\n",logviewname, newdatafile); > DP;pr_load(logviewname,newdatafile); 1907,1908c2038,2039 < dprintf("Found FR.\n"); < pr_free(); --- > dprint("Found FR.\n"); > DP; pr_free(); 1913c2044 < dprintf1arg("Found VN with viewname %s.\n",viewname); --- > dprints("Found VN with viewname %s.\n",viewname); 1918c2049 < dprintf("Found SP\n"); --- > dprint("Found SP\n"); 1931c2062 < dprintf1arg("Unknown pkey %s: skipping \n", token); --- > dprints("Unknown pkey %s: skipping \n", token); 1934c2065 < dprintf2args("Found Add with pkey %s, rest %s.\n",temppkey,addlist); --- > dprintss("Found Add with pkey %s, rest %s.\n",temppkey,addlist); 1937a2069 > hcg_parse(hcg_buffer,datafile,&idx); /*a garble may be a bug here - RJL 031022*/ 1941c2073,2075 < return (command); /* needed for second switch(command) which */ --- > return (command); /* needed for second switch(command) which is in */ > /* bdeReplay's replay_log byt may not be needed. */ > 1949c2083 < /* This function is used to replay a logsession based on */ --- > /* This function is used to replay a logged session based on*/ 1951,1952c2085,2087 < /* replace the DB from the start of the log session, */ < /* reproduce the DB modifications based on the logfile. */ --- > /* restore the DB from the checkpoint *DB1.dat file, */ > /* and reproduce the DB modifications from the change-log. */ > /* Note: startlog during replay is untested and may fail */ 1964a2100,2109 > /* */ > /* Pre-conditions (added by RJL 030809) */ > /* (name without extension) cannot include "." */ > /* DB1.dat exists to initialize database */ > /* logdata.txt must contain "LogDataFile\n" plus data */ > /* for each file copy that pr_init will scan. */ > /* (hcg_replay == 1) (from "SR" command; reset here) */ > /* pr_load sets hcg_log = 0 and returns retval. */ > /* Is this BAD if retval = -4? */ > /* */ 1966c2111 < /* 0 - success */ --- > /* 0 - success [or no-op? - RJL 040520] */ 1969c2114 < /* -3 - Replay error - unable to open file */ --- > /* -3 - Replay error - unable to open some tempfile */ 1971c2116,2117 < /* -5 - Replay error - incorrect log file format */ --- > /* -5 - Replay error - Missing "LogFileData" header */ > /* -6 - Replay error - already doing replay - RJL 040520 */ 1974c2120,2126 < int pr_replay(char *view,char logfile[NAMELENGTH],int near_realtime,int take_endsnapshot) --- > /* Note added by RJL - 040520: */ > /* replay occurs only #ifdef GENLOG - if assume pr_log.c*/ > /* doesn't even exist unless #ifdef GENLOG - RJL 040520?*/ > /********************************************************/ > > int pr_replay(char *view, char logfile[NAMELENGTH], > int near_realtime, int take_endsnapshot) 1977,1979c2129,2137 < char filelist[BUFSIZE], tempfilelist[BUFSIZE],tempvar[BUFSIZE], logfiledb[NAMELENGTH]; < int retval; < --- > char filelist[BUFSIZE], tempfilelist[BUFSIZE], > tempvar[BUFSIZE], logfiledb[NAMELENGTH]; > int retval = 0; > filelist[0] = '\0'; > EP; > #ifdef DEBUG > printf("pr_replay:BUFSIZE=%i, NAMELENGTH=%i, filelist=\n\t%s\n", > BUFSIZE, NAMELENGTH, filelist); > #endif 1980a2139 > /* range constraint pre-condition - should be an enumeration */ 1983,1984c2142,2143 < printf("pr_replay error: logging in progress\n"); < return(-4); --- > printf("Error: pr_replay invalid - logging in progress\n"); > return -4; // hcg_log = 1 1985a2145,2146 > /* TBD: Allow "SR" command AFTER loading valid data? */ > /* Why? - replay already permits pr_adding rows after "SR". */ 1987,1990c2148,2152 < /* set replay to be on & save logfilename*/ < hcg_log = 2; < strcpy(hcg_logfile,logfile); < --- > if (hcg_log == 2) { > printf("Error: recursive pr_replay invalid - already doing replay\n"); > return -6; // hcg_log = 2 > } > assert(hcg_replay); // was assert(hcg_log==0); - RJL 040712 1994,1995c2156 < hcg_log = 0; < return(-1); --- > return(-1); // hcg_log = 0 1999,2000c2160 < hcg_log = 0; < return(-2); --- > return(-2); // hcg_log = 0 2003,2005c2163,2167 < /* free the existing database */ < if (hcg_initialized) { < pr_free(); --- > /* set replay to be on & save logfilename*/ > hcg_replay = 1; // was hcg_log = 2 - RJL 040712 > strcpy(hcg_logfile, logfile); //hcg_logfile scope is? > if (hcg_initialized) { /* free the existing database */ > DP; pr_free(); // clears hcg_initialized = 0; 2008,2009c2170,2173 < /* generate the data files */ < strtok(logfile,"."); --- > strtok(logfile,"."); /* assumes exactly one period */ > // TBD: see pr_load.c:2967:int stripDPath > > /* generate checkpoint file name by appending "DB1" */ 2011,2012c2175 < log_parselogdata(tempfilelist); < sprintf(filelist,"%s %s",tempfilelist, logfiledb); --- > /*Pre-condition: infile logdata.txt MUST exist here - RJL 030809 */ 2014c2177 < dprintf1arg("filelist: %s \n\n", filelist); --- > retval = log_parselogdata(tempfilelist); 2015a2179,2185 > if (retval != 0) > return(retval); /* Why quit now? - RJL 040404 */ > > sprintf(filelist, "%s %s", > tempfilelist, logfiledb); > > dprints("pr_replay: filelist to pr_init: \n\t%s\n\n", filelist); 2017,2018c2187,2199 < pr_init("../lib/bdetest.viewdefs",filelist); < pr_load(view,logfiledb); --- > /* GENLOG is a link-time pre-condition for generating pr_log.c */ > DP; pr_init("../lib/bdetest.viewdefs", tempfilelist); //hcg_initialized = 1; > /* get stats from tempfilelist and logfiledb: RJL 030809*/ > DP; pr_load(view, logfiledb); /* checkpoint initializes VMNetDB */ > > /* DO THE REPLAY HERE: */ > retval = 0; /* unless replay_log returns another value */ > retval = replay_log(); /* compiled only #ifdef GENLOG */ > > /* HGcurr != NULL fails in replay_log at bdeReplay.cc, line 403-RJL040904i */ > /* NB: CLIENT must have a stub for this, which is an */ > /* application-specific part of replaying the logfile */ > /* e.g., bdeReplay.cc contains a work-completion function after replay_log. */ 2020,2026c2201 < /* replay the log */ < #ifndef BDELOG < retval = replay_log(); < if ( retval != 0 ) { < hcg_log = 0; < return(retval); < } --- > hcg_replay = 0; /* this replay interval is ended */ 2031c2206,2207 < pr_dump(view, tempvar,0,"w"); --- > DP; pr_dump(view, tempvar,0,"w"); > dprints("endSnapshot is in file %sDB3.dat\n", logfile); 2033c2209 < #endif --- > // #endif 2035,2037c2211,2215 < hcg_log = 0; < return (0); < } --- > assert (hcg_log == 2); // RJL 040520 > hcg_log = 0; /* replay finished; resume normal editing */ > /* TBD: allow logging during replay and both afterward - RJL 030807 */ > return (retval); > } // end pr_replay 1:1c1 5:5c5,16 20:14a26 22:16,17c28 27:19c30 31:24c35,38 38:41c55 42:44,45c58,60 49:64c79 53:86,89d100 58:91c102 62:93c104 66:185c196 70:277c288 74:353c364 78:398c409 82:456c467 86:458d468 88:467c477 92:473c483,484 97:475c486 101:477,483c488 111:484a490 113:492c498 117:494,497c500,503 127:499,500c505 132:516c521 136:518c523 140:521c526 144:526c531 148:540,541c545,549 157:555c563 161:564c572 165:566c574 169:568c576 173:576c584 177:580,584c588,589 186:591c596 190:600c605,606 195:602,610c608,623 222:612,613c625,626 228:619c632,633 233:622c636,637 238:625,627c640,643 247:629,630c645,647 254:633,634c650,651 260:635a653 262:641,642c659,662 270:648a669 272:652a674 274:655c677 278:660c682,683 283:662c685 287:670,671c693 292:680c702 296:687a710 298:719c742 302:727c750,751 307:783c807,808 312:1025c1050 316:1028c1053 320:1033a1059,1063 326:1036c1066 330:1037a1068 332:1039c1070,1075 341:1042c1078 345:1044,1045c1080,1081 351:1127,1128c1163,1164 357:1146a1183 359:1149,1152c1186,1197 377:1159,1160c1204,1205 383:1168c1213 387:1189a1235 389:1263,1265c1309,1315 401:1280c1330,1332 407:1283a1336 409:1286,1289c1339,1350 427:1442,1443c1503 432:1458c1518,1528 446:1462,1463c1532,1534 453:1465,1469c1536,1562 487:1471c1564 491:1472a1566,1571 498:1475c1574,1575 503:1482a1583 505:1505c1606 509:1514a1616 511:1600,1602c1702,1703 518:1617c1718,1719 523:1620a1723 525:1623,1626c1726,1737 543:1775,1776c1886 548:1784a1895 550:1786c1897 554:1788a1900,1901 557:1793a1907,1910 562:1803a1921,1923 566:1805c1925,1926 571:1806a1928,1931 576:1815a1941,1944 581:1827a1957 583:1836c1966 587:1844c1974 591:1850a1981 593:1888c2019 597:1892,1893c2023,2024 603:1901,1902c2032,2033 609:1907,1908c2038,2039 615:1913c2044 619:1918c2049 623:1931c2062 627:1934c2065 631:1937a2069 633:1941c2073,2075 639:1949c2083 643:1951,1952c2085,2087 650:1964a2100,2109 661:1966c2111 665:1969c2114 669:1971c2116,2117 674:1974c2120,2126 684:1977,1979c2129,2137 698:1980a2139 700:1983,1984c2142,2143 706:1985a2145,2146 709:1987,1990c2148,2152 720:1994,1995c2156 725:1999,2000c2160 730:2003,2005c2163,2167 740:2008,2009c2170,2173 748:2011,2012c2175 753:2014c2177 757:2015a2179,2185 765:2017,2018c2187,2199 782:2020,2026c2201 792:2031c2206,2207 797:2033c2209 801:2035,2037c2211,2215