Thoughts from Dan Miser RSS 2.0
# Saturday, December 04, 2004
Using DBX, we came across a bug where the values for the fields in the first record were not available in the OnCalcFields event. After doing some digging, I found that this was already reported as QC 1328. I noticed that the problem was marked as Fixed in Delphi 2005, and we are still using Delphi 6, so that would explain it.

I then went and modified my own test case, and the one reported in QC and noticed that both of these test cases still exhibited the problem in D2005. I talked to a couple of friends in Scotts Valley, and they confirmed the behavior as still being present in Win32 in D2005. So, it turns out that the fix only made it to the VCL.NET side of things. At least that source is similar enough to figure out what's going on.

The problem exists in TDataset.GetCalcFields. Take a look at the VCL.NET implementation in D2005 for the complete code. However, I still needed to get the fix into our codebase, and we won't be upgrading everything to D2005 for a little bit yet. We also can't just patch the VCL in the DB.pas unit since we are using runtime packages on our app servers in order to pass VCL components around.

With all of these requirements in place, I set out to create a descendant of TSQLQuery and override GetCalcFields. This turned out to be problematic, however, due to the fixed code's need to set the FEOF private variable in TDataset. I realized that the EOF property is read-only and that the backing field is private, so I used Hallvard's Hack #1. This works absolutely flawlessly, and I now have the fix isolated to one place so that when we upgrade to D2005, I can simply remove this new component in the handful of places that it gets used.

Here is the implementation code that I finally came up with:


type
  TDatasetEx = class(TDataset)
  published
    property EOF;
  end;

procedure TDRMSQLQuery.SetEOF(Value: boolean);
begin
  PBoolean(Integer(Self) + (Integer(GetPropInfo(TDatasetEx, 'EOF').GetProc) and $00FFFFFF))^ := Value;
end;

{$WARNINGS OFF}
// We are guaranteed that the only time we both set and use eofBak is when
// State = dsInactive. Therefore, we don't care about the warning.
procedure TDRMSQLQuery.GetCalcFields(Buffer: PChar);
var
  eofBak: Boolean;
begin
  if (State = dsInactive) then
  begin
    eofBak := EOF;
    SetEOF(False);
  end;

  try
    inherited GetCalcFields(Buffer);
  finally
    if (State = dsInactive) then
      SetEOF(eofBak);
  end;
end;

Notes:

  • I would fully expect that Borland will fix this fully in an upcoming D2005 patch.
  • Thanks to Joerg and John (from Borland) for helping out with this one.
  • The problem does not exist in the BDE, just DBX. I haven't checked other data access layers (ADO, IBX, DOA, etc.), but if they have the same problem, then you can use something like this technique to fix it for now. Since the true fix is in TDataset, all other implementations will be fixed automatically when that fix is rolled out.
Saturday, December 04, 2004 1:41:00 PM (Central Standard Time, UTC-06:00)  #    Comments [2] -
Delphi
Tracked by:
http://9nl-information.info/58568428/index.html [Pingback]
http://9ni-information.info/95111904/index.html [Pingback]
http://9nq-information.info/47341026/index.html [Pingback]
http://9nw-information.info/36977773/index.html [Pingback]
http://9np-information.info/79179946/index.html [Pingback]
http://9nx-information.info/08017232/first-colerd-tv-show.html [Pingback]
http://9nh-information.info/98937425/nln-medication-test-study-guide.html [Pingback]
http://9np-information.info/44132716/index.html [Pingback]
http://9nl-information.info/06103270/index.html [Pingback]
http://9nq-information.info/88195615/index.html [Pingback]
http://9ng-information.info/80990121/travel-guide-to-michigan.html [Pingback]
http://9on-information.info/41585738/index.html [Pingback]
http://9qd-information.info/27785035/russian-escort-italy.html [Pingback]
http://9of-information.info/40584884/index.html [Pingback]
http://9or-information.info/31488524/index.html [Pingback]
http://9op-information.info/85584817/index.html [Pingback]
http://9qr-information.info/41133643/acer-pd-116.html [Pingback]
http://9qr-information.info/23542409/index.html [Pingback]
http://9ro-information.info/43825384/internet-sales-ranking.html [Pingback]
http://9rk-information.info/62032835/smoker-wood-manuka.html [Pingback]
http://9si-information.info/61489899/splendid-hotel-cortina-d-ampezzo.html [Pingback]
http://9rs-information.info/29153434/index.html [Pingback]
http://9sb-information.info/66966328/t430.html [Pingback]
http://9rr-information.info/42028379/index.html [Pingback]
http://9sp-information.info/75814474/index.html [Pingback]
http://9sa-information.info/27918731/pc-packard-bell-mc-9120.html [Pingback]
http://9rs-information.info/89335105/index.html [Pingback]
http://9uaeb-le-informazioni.info/44013957/aerosoles.html [Pingback]
http://9uaec-le-informazioni.info/25511529/index.html [Pingback]
http://9uaei-le-informazioni.info/38583983/index.html [Pingback]
http://9uaeo-le-informazioni.info/51402763/index.html [Pingback]
http://9uafm-le-informazioni.info/39626894/index.html [Pingback]
http://9uafr-le-informazioni.info/12163809/index.html [Pingback]
http://9uaed-le-informazioni.info/18528611/audison-srx3.html [Pingback]
http://9uafj-le-informazioni.info/69454152/index.html [Pingback]
http://9uaea-le-informazioni.info/12236595/quando-potare-i-gerani.html [Pingback]
http://9uaes-le-informazioni.info/30697886/index.html [Pingback]
http://9uaea-le-informazioni.info/81197433/lingua-letteratura-inglese.html [Pingback]
http://9uaha-le-informazioni.info/78052875/merz-sergio.html [Pingback]
http://9uahl-le-informazioni.info/89023485/love-shakespeare.html [Pingback]
http://9uaho-le-informazioni.info/80661690/mistress-damiana-chi.html [Pingback]
http://9uahr-le-informazioni.info/14349068/win-mx-italiano-download.html [Pingback]
http://9uahi-le-informazioni.info/45079106/index.html [Pingback]
http://9uage-le-informazioni.info/50104832/index.html [Pingback]
http://9uagt-le-informazioni.info/85387599/index.html [Pingback]
http://9uaht-le-informazioni.info/80337805/index.html [Pingback]
Saturday, December 04, 2004 2:56:00 PM (Central Standard Time, UTC-06:00)
Here's hoping the VCL doesn't become the poor cousin to the VCL.NET in terms of bug fixes. It will be a long time before there are more VCL.NET applications out there than VCL apps (if ever).
Saturday, December 04, 2004 7:00:00 PM (Central Standard Time, UTC-06:00)
Call me the eternal optimist, but I'm not that worried about that. My complete WAG as to how this happened is that during the long development cycle of getting VCL.NET up and running, the developers needed to start remembering to fix bugs in both places. All the while, they were doing totally new stuff. It's not surprising that a couple things got out of sync along the way while the team learned a new process.



However, now that the team has gone through a full cycle of new development AND bug fixing, I'm betting that future bug fixes will make it into both places on a regular basis. Of course, they are human, so things may get messed up once in a great while, but I'm supremely confident of the technical abilities of the R&D teams at Borland.



Besides, a fix like this one wouldn't take a whole lot more effort to port to the other environment once you have the fix. So, I'm very inclined to write this off to "process learning".
Comments are closed.
Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)