BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCustomClientDataset.GetRecord -> "GetSequenceNumber" and db

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Martijn Tonies
Guest





PostPosted: Tue Sep 12, 2006 7:37 pm    Post subject: TCustomClientDataset.GetRecord -> "GetSequenceNumber" and db Reply with quote



Hi,

Righto, this will be a "how do the internals work" post.

A customer asked about an exception he was getting with ApplyUpdates
when using our dbExpress driver for Firebird, while he wasn't getting
this error with the InterBase driver.

Well, here's the thing --

TCustomClientDataset.GetRecord calls, after .Append(ing) a record
and calling ApplyUpdates, a method from its "DSCursor" it has, here:

function TCustomClientDataSet.GetRecord(Buffer: PChar; GetMode: TGetMode;
DoCheck: Boolean): TGetResult;
(get's called from .Resync)
....
....
case Status of
DBERR_NONE:
begin
if (AggFields.Count > 0) and AggregatesActive then
GetAggFieldData(Buffer);
with PRecInfo(Buffer + FRecInfoOfs)^ do
begin
BookmarkFlag := bfCurrent;
GetSequenceNumber(DWord(RecordNumber));
GetRecordAttribute(Attribute);
end;
....
....

For the InterBase driver, the call to GetSequenceNumber returns a
value equal to the number of rows, while for our driver it returns "1".
This makes the RecordNumber the same as another record number
and subsequent calls to Append and ApplyUpdates fail with a
Key Violation (not coming from the driver, but from within midas.dll!!!).

I have _no idea at all_ why this returns a different value for our driver.

I have _no idea_ if this call (from the DSCursor) calls some method
in the driver, it doesn't go into our driver, but it could be that has some
cause beyond my knowledge.


Could someone from Borland, probably someone who knows the
midas.dll internals, shed a light on this??

--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Thu Sep 28, 2006 9:31 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote



Martijn Tonies wrote:

Quote:
I have _no idea_ if this call (from the DSCursor) calls some method
in the driver, it doesn't go into our driver, but it could be that
has some cause beyond my knowledge.

It can't. Briefcase mode would never work, otherwise.

You can prove this to yourself. Write a three-tier project using
sockets. Write an intercept library that just logs what comes over the
pipe (or there's an intercept demo which you can just use as-is). Put a
breakpoint on the intercept. You'll get nothing.

I suspect that the behavior you're seeing has to do with some value
which came from the driver earlier, most likely when the data was
fetched in the first place.

Note that you can look at the data packets directly in Delphi code and
even do a binary diff on them. You could set up an app which fetched
identical data from identical DBs and reported the difference between
the packets. That might give you a clue as to where to look.

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Borland newsgroup denizen Sergio González has a new CD of
Irish music out, and it's good: http://tinyurl.com/7hgfr
Back to top
Martijn Tonies
Guest





PostPosted: Fri Sep 29, 2006 8:11 am    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote



Quote:
I have _no idea_ if this call (from the DSCursor) calls some method
in the driver, it doesn't go into our driver, but it could be that
has some cause beyond my knowledge.

It can't. Briefcase mode would never work, otherwise.

You can prove this to yourself. Write a three-tier project using
sockets. Write an intercept library that just logs what comes over the
pipe (or there's an intercept demo which you can just use as-is). Put a
breakpoint on the intercept. You'll get nothing.

I suspect that the behavior you're seeing has to do with some value
which came from the driver earlier, most likely when the data was
fetched in the first place.

Note that you can look at the data packets directly in Delphi code and
even do a binary diff on them. You could set up an app which fetched
identical data from identical DBs and reported the difference between
the packets. That might give you a clue as to where to look.

Hello Craig,

Thanks for the response -- but you've got me puzzled here :-)

How can I do what you're talking about?


--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Fri Sep 29, 2006 5:34 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote

Martijn Tonies wrote:

Quote:
How can I do what you're talking about?

Which thing? The intercept, or comparing the data packet?

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
How to ask questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html
Back to top
Martijn Tonies
Guest





PostPosted: Fri Sep 29, 2006 10:13 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote

Quote:
How can I do what you're talking about?

Which thing? The intercept, or comparing the data packet?

Both :-)


--
Martijn
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Fri Sep 29, 2006 10:45 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote

Martijn Tonies wrote:

Quote:
Which thing? The intercept, or comparing the data packet?

Both Smile

Well, there's already an intercept demo in the Demos / DB / Midas
folder which came with Delphi (I may have the folder name wrong; this
is from memory. I don't think you really need to do this, since I can
tell you what the result will be, but you might want to prove it to
yourself.

The data packet can be found at TCustomClientDataSet.Data. It's an
OleVariant containing an array of bytes. You can iterate through the
bytes one at a time to see where they differe.

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Everything You Need to Know About InterBase Character Sets:
http://blogs.teamb.com/craigstuntz/articles/403.aspx
Back to top
Martijn Tonies
Guest





PostPosted: Mon Oct 02, 2006 8:29 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote

Quote:
Which thing? The intercept, or comparing the data packet?

Both :-)

Well, there's already an intercept demo in the Demos / DB / Midas
folder which came with Delphi (I may have the folder name wrong; this
is from memory. I don't think you really need to do this, since I can
tell you what the result will be, but you might want to prove it to
yourself.

Hmm... can't find it anywhere. Could this be an "Enterprise" edition
only demo project?

Quote:
The data packet can be found at TCustomClientDataSet.Data. It's an
OleVariant containing an array of bytes. You can iterate through the
bytes one at a time to see where they differe.

Let me see what I can do ...

I'm still surprised how this behaviour can be affected by a driver though.



--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Mon Oct 02, 2006 8:48 pm    Post subject: Re: TCustomClientDataset.GetRecord -> "GetSequenceNumber" an Reply with quote

Martijn Tonies wrote:

Quote:
Hmm... can't find it anywhere. Could this be an "Enterprise" edition
only demo project?

Could well be, as you don't get sockets without Enterprise and hence
can't do that test without it. On my install it's in:

C:\Program
Files\Borland\BDS\4.0\Demos\DelphiWin32\VCLWin32\MIDAS\Intrcpt

Quote:
Let me see what I can do ...

I'm still surprised how this behaviour can be affected by a driver
though.

Can't really say until I figure out what the problem is.

The other thing you could do is compare the results of the calls into
your driver with the results of the calls into the Borland drivers. You
can pretty easily trace the arguments in and out of both drivers, even
though you don't have source for the Borland driver.

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
How to ask questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.