Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
2GB limit
Message
From
08/10/1999 07:48:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/10/1999 15:31:59
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00273939
Message ID:
00274124
Views:
35
>I have a table that is used to store audit trail information. Yesterday afternoon it reached it's 2GB limit! The app started crashing every time a user tried to save a new or changed record. We have replaced the file with a new copy and the app is back up and running.
>
>
>Now, we cannot open the old table. I need to get some information out of it. We have tried using Recover on it and that is not working. Are there any tricks that we can use to be able to open the table?


Open it lowlevel. Using recsize(), header() etc info from your copy, calculate nearest allowable size and reccount(). Using fchsize() set its size to that allowable size + replace the bytes at offset 4-7 with new reccount value.

Hope below routine helps. BTW I cannot be hold responsible for any data loss if occurs. You should do your backup yourself. #include NotResponsibleBlahBlahInfo :)
parameters tcTableName
#define TableLimit 2*1024*1024*1024
tcTableName = tcTableName + ".dbf" && Warning - no check here
handle=fopen(tcTableName,2)
lnFileSize=fseek(handle,0,2)   && File size
if lnFileSize > TableLimit
	Hsize=getword(handle,8)    && Header()
	Rsize=getword(handle,10)   && Recsize()
	lnMaxRecords = floor((TableLimit - Hsize) / Rsize ) && Max records allowable
	lnNewSize = lnMaxRecords * Rsize + Hsize
	=fchsize(handle, lnNewSize) && Resize file
	=putlong(handle,4,lnMaxRecords) && Reset reccount() in header
endif	
=FCLOSE(HANDLE)

**************************************************************************
* getbyte : get a single byte at position specified by pos from a file opened
*           with low level functions (handle comes from that function)
* getword :
* get a word size integer in hex format
* parameters : handle - file handle got by fopen() or alike
*              pos    - file position to get word
*              lr     - (Logical) if .T. left-to-right format used
*                       if .F. or not passed right-to-left format used
*                       (more likely to be used with low level)
* EXAMPLE :
* getword(handle,12)     - returns 62313 if bytes at offset 11 are ( 69 F3 )
* getword(handle,12,.T.) - returns 62313 if bytes at offset 11 are ( F3 69 )
*
* getlong : same as putword except gets 4 bytes
**************************************************************************
function getbyte
parameters handle,pos
=fseek(handle,POS,0)
return asc(fread(handle,1))

function getword
parameters handle,pos,lr
if parameters()<3
 lr=.f.
endif
=fseek(handle,POS,0)
return asc(fread(handle,1))*iif(lr,256,1)+asc(fread(handle,1))*iif(lr,1,256)

function getlong
parameters handle,pos,lr
if parameters()<3
 lr=.f.
endif
lowword=getword(handle,iif(lr,pos+2,pos),lr)
highword=getword(handle,iif(lr,pos,pos+2),lr)
return highword*65536+lowword

**************************************************************************
* putbyte : write a single to position specified by pos to a file opened
*           with low level functions (handle comes from that function)
* putword :
* put a word size integer in hex format
* parameters : handle - file handle got by fopen() or alike
*              pos    - file position to put word
*              word   - word that will be written
*              lr     - (Logical) if .T. left-to-right format used
*                       if .F. or not passed right-to-left format used
*                       (more likely to be used with low level)
* EXAMPLE :
* putword(handle,12,62313)     - writes at offset 11 ; bytes ( 69 F3 )
* putword(handle,12,62313,.T.) - writes at offset 11 ; bytes ( F3 69 )
*
* putlong : same as putword except writes 4 bytes
**************************************************************************
function putbyte
parameters handle,pos,byte
=fseek(handle,POS,0)
written=fwrite(handle,chr(byte),1)

function putword
parameters handle,pos,word,lr
if parameters()<4
 lr=.f.
endif
lowbyte=ceiling(word)%256
highbyte=int(ceiling(word)/256)
=putbyte(handle,iif(lr,pos+1,pos),lowbyte)
=putbyte(handle,iif(lr,pos,pos+1),highbyte)

function putlong
parameters handle,pos,long,lr
if parameters()<4
 lr=.f.
endif
lowword=ceiling(long)%65536
highword=int(ceiling(long)/65536)
=putword(handle,iif(lr,pos+2,pos),lowword,lr)
=putword(handle,iif(lr,pos,pos+2),highword,lr)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform