Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpt error: "Flush: Error Flushing File Buffer" #945

Closed
cpyrgas opened this issue Feb 2, 2022 · 2 comments
Closed

Fpt error: "Flush: Error Flushing File Buffer" #945

cpyrgas opened this issue Feb 2, 2022 · 2 comments
Assignees
Milestone

Comments

@cpyrgas
Copy link

cpyrgas commented Feb 2, 2022

Following code with the attached dbf/fpt causes several handled and unhandled exceptions. In VO it seems to work fine

dbffpt.zip

XSharp.RDD.RddError
Flush: Error Flushing File Buffer 

Callstack : 
System.Void XSharp.RDD.DBF._dbfError(System.Exception ex, System.UInt32 iSubCode, System.UInt32 iGenCode, System.String strFunction, System.String strMessage, System.UInt32 iSeverity, System.Boolean lThrow)() 
Byte[] XSharp.RDD.FPTMemo._getBlock(System.Int32 blockNbr)() 
Byte[] XSharp.RDD.FPTMemo.GetRawValueWithHeader(System.Int32 nFldPos)() 
XSharp.RDD.DBFCDX.Object XSharp.RDD.DBFFPT.GetValue(System.Int32 nFldPos)() 
Object XSharp.RDD.DBFCDX.GetValue(System.Int32 nFldPos)() 
XSharp.CoreDb+<>c__DisplayClass42_0.Boolean XSharp.CoreDb+<>c__DisplayClass42_0.<FieldGet>b__0()() 
static Object XSharp.CoreDb.Do(System.Func`1[System.Object] action)() 
static Boolean XSharp.CoreDb.FieldGet(System.UInt32 nPos, System.Object oRet)() 
static Boolean XSharp.VoDb.FieldGet(System.UInt32 nPos, XSharp.__Usual uRet)() 
VO.DbServer.System.Void VO.DbServer.__InitRecordBuf()() 
VO.DbServer.System.Void VO.DbServer..ctor(XSharp.__Usual[] Xs$Args)() 


FUNCTION Start( ) AS VOID
/*	SetAnsi          	(TRUE)
	SetExclusive    	(FALSE)
	SetDeleted       	(TRUE)
	SetCollation     	(#CLIPPER)
	SetInternational 	(#CLIPPER)
	SetNatDLL 		("German.dll")
*/
	
	LOCAL cOld AS STRING
	LOCAL cNew AS STRING
	LOCAL odbServerOld AS dbServer
	LOCAL odbServerNew AS dbServer
	LOCAL nRecno,nRecno2 AS DWORD
	LOCAL aStruct AS ARRAY

	LOCAL cPath AS STRING
	cPath := "C:\Test\"
//	cPath := "C:\xSharp\Users\Horst\XS_Test\"
	
	RddSetDefault 	("DBFCDX")

	aStruct := {  { "IS_FAKTURA","L",1,0 } ,;
                  { "ARTIKEL1","C",60,0 } ,;
                  { "ARTIKEL2","C",30,0 } ,;
                  { "ARTIKEL3","C",30,0 } ,;
                  { "FTEXTBLOCK","M",10,0 } ,;
                  { "GRUPPE","C",20,0 } ,;
                  { "SCHRIFT","C",1,0 } ,;
                  { "DIMENSION","C",30,0 } }
	
	nRecno  := 2
	nRecno2 := nRecno -1
	
	cOld := cPath + "OLD"
	cNew := cPath + "NEW"

	DbCreate(cNew,aStruct,"DBFCDX")
	
	odbServerOld := dbServer { cOld, DBSHARED, FALSE}
	oDbServerNew := dbServer { cNew, DBSHARED, FALSE }

	odbServerNew:AppendDB (odbServerOld, , {|| RecNo () < nRecno})
	odbServerNew:Append ()
	odbServerNew:AppendDB (odbServerOld, , {|| RecNo () > nRecno2})

	odbServerOld:Close ()
	odbServerNew:Close ()
	

	odbServerNew 	:= dbServer { cNew, DBSHARED, TRUE }
	odbServerNew:GoTop ()
	
	? "Recno after GoTop:", NTrim (odbServerNew:recno)
	
	DO WHILE ! odbServerNew:eof      
		? "Recno:", NTrim (odbServerNew:recno)
		? "Contents:", AllTrim(odbServerNew:FIELDGET (#FTextblock))
		odbServerNew:Skip ()
	ENDDO
	odbServerNew:Close()
	
RETURN 
@RobertvanderHulst RobertvanderHulst self-assigned this Feb 2, 2022
@RobertvanderHulst RobertvanderHulst added this to To do in February 2022 via automation Feb 2, 2022
@RobertvanderHulst
Copy link
Member

The problem is in the code behind the AppendDB() method.
This code uses the DbTrans() method which calls into the RDD and asks the RDD if it supports "PutRec".
When the RDD supports GetRec() and PutRec() then the whole record buffer from the source table is copied to the target table and individual fields are not written.
The question for PutRec() is only asked when the source and target tables have the same structure like in the example.
The default DBF RDD does support that, but it ignores to check if the table has memo fields.
In the example you can see that if you add one extra field to the "New" table. In that case the structure of the source and target tables is different and the system does not even try to perform a "PutRec".

@RobertvanderHulst RobertvanderHulst moved this from To do to Needs Testing in February 2022 Feb 2, 2022
February 2022 automation moved this from Needs Testing to Done Feb 2, 2022
@RobertvanderHulst RobertvanderHulst moved this from Done to Needs Testing in February 2022 Feb 2, 2022
February 2022 automation moved this from Needs Testing to In progress Feb 2, 2022
@cpyrgas
Copy link
Author

cpyrgas commented Feb 2, 2022

Confirmed fixed!

@cpyrgas cpyrgas closed this as completed Feb 2, 2022
February 2022 automation moved this from In progress to Needs Testing Feb 2, 2022
@cpyrgas cpyrgas moved this from Needs Testing to To do in February 2022 Feb 2, 2022
@cpyrgas cpyrgas moved this from To do to Done in February 2022 Feb 2, 2022
@RobertvanderHulst RobertvanderHulst added this to the X# 2.11 milestone Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants