tldm-universe/Ardent/UV/APP.PROGS/VERF.SCHEMS.B
2024-09-09 17:51:08 -04:00

190 lines
5.7 KiB
Plaintext
Executable File

*******************************************************************************
*
* SQL catalog verification tool.
*
* 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.
*
*******************************************************************************
*
* Maintenance log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 10/14/98 23801 SAP Change copyrights.
* 03/13/96 17797 AGM Replace SH and DOS with OS.EXEC
* 01/25/96 17671 LAG Windows NT port
* 07/18/93 10131 DPB Initial creation of catalog verification tool.
*
*******************************************************************************
*
* VERIFY.SCHEMAS(Fix, Brief, VTables)
*
* This subroutine will verify the SQL catalog contents for all schemas.
*
* Fix This boolean variable indicates whether or not any
* discrepencies found should be fixed.
* Brief This boolean variable indicates the amout of output
* expected from the subroutine. When turned on only
* extrememly critical problems are reported.
* VTables This boolean variable indicates whether of not the
* tables associated with the schema should be verified.
*
*******************************************************************************
SUBROUTINE VERIFY.SCHEMAS(Fix, Brief, VTables)
INCLUDE UNIVERSE.INCLUDE VERIFY.COM
INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
******************
** Windows NT port
**
DEFFUN IS.FULLPATH(FILESPEC) CALLING "*IS.FULLPATH"
DEFFUN IS.EQPATHS(FILESPEC.A, FILESPEC.B) CALLING "*IS.EQPATHS"
DEFFUN GET.DIRNAME(FILESPEC) CALLING "*GET.DIRNAME"
DEFFUN GET.BASENAME(FILESPEC) CALLING "*GET.BASENAME"
**
******************
Verbose = NOT(Brief) ;* Opposite of Brief. (Saves opcodes)
GOSUB BUILDLIST:
FOR I = 1 to SchemaCount
CALL *WRAP.PRINT(" ",Width,0,0)
CALL *WRAP.PRINT("Verifying schema '":SchemaList<I>:"'.",Width,0,0)
CALL *VERIFY.SCHEMA(Schemas<I>, Fix, Brief, VTables)
NEXT I
FOR I = 1 to DCOUNT(Plist,@FM)
IF I = 1
THEN
CALL *WRAP.PRINT(" ",Width,0,0)
CALL *WRAP.PRINT("These schemas could not be verified (due to OS or SQL permissions):",Width,0,0)
END
CALL *WRAP.PRINT("** Schema '":Plist<I>:"' located in '":PPlist<I>:"'.",Width,0,3)
FECount += 1
NEXT I
RETURN
BUILDLIST:
IF LPTR THEN CRT "Searching entire system for schemas. This may take a while."
IF Verbose THEN CALL *WRAP.PRINT("Searching entire system for schemas. This may take a while.",Width,0,0)
******************
** Windows NT port
**
IF OS.TYPE = "UNIX"
THEN
EXECUTE "SH -c 'find / -name VOC -exec ":UV.ROOT:"/bin/UVfile -s {} \;'" CAPTURING junk
END
ELSE
EXECUTE "DOS /C '":UV.ROOT:"/bin/uvwalk \ -name VOC -recurse -all -ntfs -uvfile'" CAPTURING junk
END
**
******************
IF Verbose THEN PRINT ON Pchan "Building schema list.":
NUMFLDS = COUNT(junk,@FM)
Schemas = ""
SchemaList = ""
SchemaPList = ""
SchemaCount = 0
Plist = ""
PPlist = ""
FOR I = 2 to NUMFLDS
IF UPCASE(junk<I>[1,13]) = "UNIVERSE/SQL:"
THEN
IF Verbose THEN PRINT ON Pchan ".":
SchemaCount = SchemaCount + 1
tmp = CONVERT(" ",@FM,junk<I>)
SchemaList<SchemaCount> = tmp<8>
******************
** Windows NT port
**
IF OS.TYPE = "UNIX"
THEN
tmp = CONVERT(":",@FM,junk<I-1>)
END
ELSE
tmp = CONVERT(": ",@FM,junk<I-1>)
END
**
******************
SchemaPList<SchemaCount> = tmp<1>
tmp = SchemaPList<SchemaCount>[1,LEN(SchemaPList<SchemaCount>)-4]
SchemaPList<SchemaCount> = tmp
Schemas<SchemaCount> = tmp
I = I+1
END
NEXT I
SELECTV uvschema TO schemlist
done = 0
LOOP
READNEXT id FROM schemlist ELSE done = 1
WHILE NOT(done)
READ srec FROM uvschema,id ELSE CONTINUE
LOCATE(srec<2>,SchemaPList;tmp)
THEN
IF SchemaList<tmp> # id
THEN
INS id BEFORE Plist<-1>
INS srec<2> BEFORE PPlist<-1>
END
END
ELSE
IF Verbose THEN PRINT ON Pchan ".":
CHKNAME = srec<2>:"/VOC"
GOSUB GETSCHEMA
IF GetName = -1
THEN
INS id BEFORE Plist<-1>
INS srec<2> BEFORE PPlist<-1>
END
ELSE
SchemaCount = SchemaCount + 1
SchemaPList<SchemaCount> = srec<2>
SchemaList<SchemaCount> = id
Schemas<SchemaCount> = id
END
END
REPEAT
IF Verbose THEN PRINT ON Pchan ".done"
RETURN
GETSCHEMA:
EXECUTE OS.EXEC:" '":UV.ROOT:"/bin/UVfile -s ":CHKNAME:"'" CAPTURING junk
IF junk<1>[1,8] = "[EACCES]"
THEN
GetName = -1
END
ELSE IF INDEX(junk,"Permission denied",1)
THEN
GetName = -1
END
ELSE IF junk<1>[LEN(junk<1>)-24,LEN(junk<1>)] = "No such file or directory"
THEN
GetName = -2
END
ELSE
IF junk = ""
THEN
GetName = 0
END
ELSE
junk = CONVERT(" ",@FM,junk<2>)
GetName = junk<DCOUNT(junk,@FM)>
IF GetName = "" THEN GetName = -3
END
END
RETURN