****************************************************************************** * * System Admin Transaction Logging - Delete Log File * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intended * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description........................................ * 11/19/98 23999 RGA Add RECIO callout to update 'Rawlist'. * 10/14/98 23801 SAP Change copyrights. * 06/26/98 23161 RGA Raw Device Support * ******************************************************************************* id = "%W%" ******************************************************************************* * Inserts $INCLUDE UNIVERSE.INCLUDE TLOG.H $INCLUDE UNIVERSE.INCLUDE MACHINE.NAME $INCLUDE UNIVERSE.INCLUDE FILENAMES.H * Equates EQU VALID.SEQUENCE.NUMBER LIT 'SEQUENCE.NUMBER MATCHES "0N" AND SEQUENCE.NUMBER # 0' * Initialize FIRSTCHECK = @TRUE OPENED.FLAG = @FALSE DICT.OPENED.FLAG = @FALSE DICT.LOCKED.FLAG = @FALSE LARGEST.OFFSET = 0 INOFFSET = 0 ALF$RELEASED = "R" * Check that this user is a system administrator ALLOWED = 0 CALL *ISUSER.B(0, ALLOWED) IF NOT(ALLOWED) THEN ERROR = NOT.ADMINISTRATOR.ERROR GOSUB ERROR.SUB GOTO EXIT END * Do some initialization GOSUB INIT FOR J = 1 TO SEQ.NUMBER * find the log file with the smallest offset FOR I = 1 to SEQUENCE.NUMBER GOSUB FINDSM.LOGFILE NEXT I * process list of log file numbers - we have at least one * we only allow the deletion if no other log file has a smaller * offset - thus avoiding holes in the 'raw' device. * FOR I = 1 TO SEQUENCE.NUMBER GOSUB DELETE.LOGFILE NEXT I FIRSTCHECK = @TRUE LARGETS.OFFSET = 0 NEXT J * Finished GOTO EXIT *==== INIT: *==== * Parse command line TMP = TRIM( @SENTENCE ) CNT = COUNT( TMP, " " ) IF ( CNT NE 1 ) THEN ERROR = INCORRECT.NUM.ARGS GOSUB ERROR.SUB GOTO EXIT STOP END SEQ.NUMBER = FIELD( TMP, " ", 2 ) PATH = "" RECIO( PATH, RECIO$RAWPATH ) IF PATH = "" THEN ERROR = INVALID.UV.LOGS.DIR.ERROR GOSUB ERROR.SUB GOTO EXIT END * Open UV.LOGS OPEN '', UV.LOGS.FILE.NAME TO UV.LOGS.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.ERROR GOSUB ERROR.SUB GOTO EXIT END OPENED.FLAG = @TRUE * Open DICT UV.LOGS OPEN 'DICT', UV.LOGS.FILE.NAME TO UV.LOGS.DICT.FVAR ELSE ERROR = CANNOT.OPEN.UV.LOGS.DICT.ERROR GOSUB ERROR.SUB GOTO EXIT END DICT.OPENED.FLAG = @TRUE * Lock UV.LOGS to protect us from other users READU LOG.NEXT FROM UV.LOGS.DICT.FVAR, "LOG.NEXT" ELSE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR GOSUB ERROR.SUB GOTO EXIT END SEQUENCE.NUMBER = LOG.NEXT<2> - 1 DICT.LOCKED.FLAG = @TRUE AL.DIRECTORY = '' RECIO (AL.DIRECTORY, RECIO$RAWPATH) RETURN *============= FINDSM.LOGFILE: *============= * Open the After-Image logfile FILENAME = AL.PREFIX : SEQUENCE.NUMBER * Determine state of the file AI.REC = "" READ AI.REC FROM UV.LOGS.FVAR, I ELSE RETURN END FILE.STATE = AI.REC< AIF.STATUS > * If file state not RELEASED - 'R' we return * otherwise any log file merits consideration * to avoiding creation of holes IF FILE.STATE EQ ALF$RELEASED THEN RETURN END IF (FIRSTCHECK) THEN LARGEST.OFFSET = AI.REC< AIF.OFFSET > END * Delete only if the offset is INOFFSET = AI.REC IF ( INOFFSET > LARGEST.OFFSET) THEN LARGEST.OFFSET = INOFFSET END FIRSTCHECK = @FALSE RETURN *============= DELETE.LOGFILE: *============= * Open the After-Image logfile FILENAME = AL.PREFIX : SEQUENCE.NUMBER * Determine state of the file AI.REC = "" READ AI.REC FROM UV.LOGS.FVAR, I ELSE RETURN END FILE.STATE = AI.REC< AIF.STATUS > * If file state not EMPTY, return IF FILE.STATE # ALF$EMPTY THEN RETURN END * Delete only if the offset is INOFFSET = AI.REC IF ( INOFFSET < LARGEST.OFFSET ) THEN RETURN END * Remove entries from 'Rawlist' DUMMY = -1; RECIO( SEQUENCE.NUMBER, DUMMY, DUMMY, RECIO$RAWCREATE ) * Delete record from UV.LOGS files DELETE UV.LOGS.FVAR, I ELSE ERROR = CANNOT.DELETE.CURR.LOGFILE.ERROR GOSUB ERROR.SUB GOTO EXIT END * Print message PRINT PRINT "Deleting " : FILENAME * Reset next available SEQUENCE.NUMBER = SEQUENCE.NUMBER - 1 REC="" REC<1>="X" REC<2>=SEQUENCE.NUMBER + 1 WRITEU REC TO UV.LOGS.DICT.FVAR,"LOG.NEXT" ELSE ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR GOSUB ERROR.SUB GOTO EXIT END RETURN *========= ERROR.SUB: *========= * Error handling routine PRINT @SYS.BELL * Set return code and report the error BEGIN CASE CASE ERROR = NOT.ADMINISTRATOR.ERROR PRINT 'Error: Only the UniVerse Administrator can DELETE log files.' CASE ERROR = CANNOT.OPEN.UV.LOGS.ERROR PRINT 'Error: Cannot open UV.LOGS file, Status = ' : STATUS() CASE ERROR = UV.LOGS.IS.LOCKED.ERROR PRINT 'Error: The UV.LOGS file is currently locked by another user.' CASE ERROR = UV.LOGS.DICT.IS.LOCKED.ERROR PRINT 'Error: The DICT UV.LOGS file is currently locked by another user.' CASE ERROR = CANNOT.READ.UV.LOGS.ERROR PRINT 'Error: Reading from UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.ERROR PRINT 'Error: Writing to UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.WRITE.UV.LOGS.DICT.ERROR PRINT 'Error: Writing to DICT UV.LOGS file, Status = ' : STATUS() CASE ERROR = CANNOT.DELETE.CURR.LOGFILE.ERROR PRINT 'Error: Cannot DELETE CURRENT log file "' : FILENAME : '".' CASE ERROR = FILE.STATE.NOT.EMPTY.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not empty."' CASE ERROR = LOGFILE.NOT.FULL.ERROR PRINT 'Error: Log file "' : FILENAME : '" is not full."' CASE ERROR = INVALID.UV.LOGS.DIR.ERROR PRINT 'Error: No Logging Directory Exists.' CASE ERROR = INCORRECT.NUM.ARGS PRINT 'Error: Incorrect number of arguments' END CASE RETURN *--------------- EXIT: *--------------- * RELEASE the lock and close UV.LOGS IF DICT.LOCKED.FLAG THEN RELEASE UV.LOGS.DICT.FVAR END IF OPENED.FLAG THEN CLOSE UV.LOGS.FVAR END IF DICT.OPENED.FLAG THEN CLOSE UV.LOGS.DICT.FVAR END STOP END * END-CODE