Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Index integrity check possible?
Message
De
28/03/2007 23:35:10
Neil Mc Donald
Cencom Systems P/L
The Sun, Australie
 
 
À
28/03/2007 09:23:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Database:
Visual FoxPro
Divers
Thread ID:
01209144
Message ID:
01209564
Vues:
20
Thank Bill F he posted it on Wiki sometime ago, if memory serves me correctly.

>Neil Mc Donald, you have delivered me/us a wonderful proof that intergrity checking actually is possible! I have run the function on an actual dataset, that showed hardly noticable errors before reindexing and no errors after reindexing. Your function pointed exactly to the table and index tag that we already suspected to cause the problem!
>
>I give you one star at this moment, because I wonder whether there are types of index problems that will go unnoticed even by your function. If nobody here can come up with such types, I will give you the full three points. Thanks!
>
>>Hi,
>>See if this is what you are looking for
>>
>>LPARAMETERS l_cDataDir
>>
>>LOCAL ARRAY latables[1]
>>LOCAL ARRAY latags[1]
>>
>>LOCAL l_cCurrDir, ntables, l_nStartSeconds, nstart, ntag, lok, nreccount
>>LOCAL nrecs, coldindexexp, nend, tot, l_nEndSeconds, ii, xx
>>
>>ON ERROR errproc()
>>*SET STEP ON
>>#DEFINE CR CHR(13)+CHR(10)
>>lcLF = ALLTRIM(PROPER(ADDBS(SYS(5) + SYS(2003))+"tablelog.txt"))
>>lnLFH=FOPEN(lcLF,0)
>>IF lnLFH > 0
>>llSuccess = FCLOSE(lnLFH)
>>ERASE (lcLF)
>>ENDIF
>>
>>STRTOFILE(CR+CR+TRANSFORM(DATETIME())+CR+CR,lcLF,1)
>>CLOSE DATABASES all
>>CLEAR
>>SET EXCLUSIVE OFF
>>SET DELETED OFF
>>l_cCurrDir = SYS(5) + SYS(2003)
>>
>>IF !EMPTY(l_cDataDir)
>>	CD (l_cDataDir)
>>ELSE
>>	CD ?
>>ENDIF
>>
>>ntables=ADIR(latables,'*.DBF')
>>l_nStartSeconds = SECONDS()
>>
>>STRTOFILE("Data folder scanned - " + SYS(5) + SYS(2003) + CR + CR,lcLF,1)
>>
>>FOR ii=1 TO ntables
>>	nstart=SECONDS()
>>	USE latables[ii,1] SHARED IN 1
>>	STRTOFILE(latables[ii,1]+": ",lcLF,1)
>>	ntag=ATAGINFO(latags)
>>	FOR xx=1 TO ntag
>>		lok=.T.
>>		SET ORDER TO (latags[xx,1]) ASCENDING
>>		WAIT WINDOW "Scanning tag - " + ;
>>					latags[xx,1] + ;
>>					" in " + ;
>>					latables[ii,1] NOWAIT NOCLEAR
>>					
>>		nreccount=RECCOUNT()
>>		nrecs=0
>>		SCAN && do the fastest check first
>>			nrecs=nrecs+1
>>		ENDSCAN
>>
>>		IF nrecs#nreccount AND EMPTY(latags[xx,4])
>>			STRTOFILE("Record count failed for tag "+ latags[xx,1]+ ;
>>						" in table "+latables[ii,1]+CR,lcLF,1)
>>			lok=.F.
>>			EXIT
>>		ENDIF
>>	ENDFOR
>>	IF lok
>>		FOR xx=1 TO ntag
>>			lok=.T.
>>			SET ORDER TO (latags[xx,1]) ASCENDING
>>			coldindexexp=NULL
>>			SCAN
>>
>>				IF EVALUATE(latags[xx,3]) < coldindexexp
>>					STRTOFILE("ascending failed for tag "+ latags[xx,1]+;
>>						" in table "+latables[ii,1]+CR,lcLF,1)
>>					lok=.F.
>>					EXIT
>>				ENDIF
>>				coldindexexp=EVALUATE(latags[xx,3])
>>			ENDSCAN
>>		IF lok=.f.
>>			EXIT
>>		ENDIF
>>		ENDFOR
>>	ENDIF
>>	nend=SECONDS()
>>	tot=nend-nstart
>>	STRTOFILE([Total time for this table: ]+TRANSFORM(tot)+CR,lcLF,1)
>>ENDFOR
>>l_nEndSeconds = SECONDS()
>>
>>=STRTOFILE(CR + CR + "Total Scan time - " + ;
>>			TRANSFORM(l_nEndSeconds - l_nStartSeconds) +;
>>			" seconds" + CR,lcLF,1)
>>			
>>CLOSE DATABASES all
>>WAIT CLEAR
>>
>>CD (l_cCurrDir)
>>
>>MODIFY FILE (lcLF)
>>
>>FUNCTION errproc
>>#DEFINE CR CHR(13)+CHR(10)
>>=STRTOFILE(CR + "ERROR: "+MESSAGE() + CR,lcLF,1)
>>
>>
>>>Hi,
>>>
>>>I wonder whether it is possible to write a function that checks the integrity of a table index.
>>>
>>>Some types of index corruption can go unnoticed for quite a long time. Esp. in such a case, the advantage of an integrity check would be quite big.
>>>
>>>But there have been people here who declared it almost or entirely impossible to write a reliable integrity check.
>>>
>>>Any ideas?
Regards N Mc Donald
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform