Article View: borland.public.cppbuilder.database.ado
Article #4206Bug in Delphi or ADO driver?
From: Hannes Danzl
Date: Sun, 17 Feb 2002 22:27
Date: Sun, 17 Feb 2002 22:27
96 lines
4004 bytes
4004 bytes
Hi all.
when trying to open tables from an Oracle 8.1.x.y-ADO connection I get
occasionally VarCMP errors. I've tracked it down to
TCustomADODataset.UpdateIndexDefs. For some reason casting the values of the
SUnique and SAutoUpdate fields results in an invalid VarCMP. If that happens
for an index, all following indexdefs are not loaded, thus ending in an
incomplete list. Ok, that may be due to an invalid IndexDef recordset, but I
think Delphi suold handle this gracefully and try to load following indexes
or even better cast them correctly.
as a solution i've subclassed TAdoTable to TtvdADOTable and done the
following. Do you see any problems with this? And where to I have to send
this as a bugfix-proposal?
type
TtvdADOTable = class(TADOTable)
protected
procedure UpdateIndexDefs; override;
end;
implementation
const
cfIndex = 3;
function SafeBool(aVariant: Variant): Boolean;
begin
if VarIsNull(aVariant) then
result:=false
else
result:=varAsType(aVariant, varBoolean);
end;
type
TtvdADOCOmmand = class(TADOCOmmand); // get access to protected
ActiveConnection prop
// copy out of adodb.pas except marked changes
procedure TtvdADOTable.UpdateIndexDefs;
const
SUnique = 'UNIQUE'; { Do not localize + 5 }
SIndexName = 'INDEX_NAME';
SColumnName = 'COLUMN_NAME';
SPrimaryKey = 'PRIMARY_KEY';
SAutoUpdate = 'AUTO_UPDATE';
SOrdinalPosition = 'ORDINAL_POSITION';
var
IndexInfo: _Recordset;
aValue: Variant;
begin
try
FieldDefs.Update;
IndexDefs.Clear;
if (CommandType in [cmdTable, cmdTableDirect]) and (CommandText <> '')
then
begin
SetConnectionFlag(cfIndex, True);
try
IndexInfo :=
ttvdADOCommand(Command).ActiveConnection.OpenSchema(adSchemaIndexes,
VarArrayOf([Unassigned, Unassigned, Unassigned, Unassigned,
CommandText]),
EmptyParam);
while not IndexInfo.EOF do
begin
if TagVariant(IndexInfo.Fields[SOrdinalPosition].Value).ulVal > 1
then
with IndexDefs.Find(IndexInfo.Fields[SIndexName].Value) do
Fields := Format('%s;%s', [Fields,
IndexInfo.Fields[SColumnName].Value])
else
with IndexDefs.AddIndexDef do
begin
Name := VarToStr(IndexInfo.Fields[SIndexName].Value);
Fields := VarToStr(IndexInfo.Fields[SColumnName].Value);
aValue:=IndexInfo.Fields[SPrimaryKey].Value;
//hd changes start
if SafeBool(IndexInfo.Fields[SPrimaryKey].Value) = True then
Options := Options + [ixPrimary];
if SafeBool(IndexInfo.Fields[SUnique].Value) = True then
Options := Options + [ixUnique];
if SafeBool(IndexInfo.Fields[SAutoUpdate].Value) = False then
Options := Options + [ixNonMaintained];
//hd changes end
end;
IndexInfo.MoveNext;
end;
finally
SetConnectionFlag(cfIndex, False);
end;
end;
except
{ do nothing }
end;
end;
Technical Details
Message-ID:
<3c702e09$1_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!news2.euro.net!news7.euro.net!newsfeed.freenet.de!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,4906129ce074d20c,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-02-17 14:34:49 PST From: "Hannes Danzl" <hannes@danzl.danzl.at> Newsgroups: borland.public.cppbuilder.database.ado Subject: Bug in Delphi or ADO driver? Date: Mon, 18 Feb 2002 11:27:06 +1300 Lines: 99 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 203.109.148.190 Message-ID: <3c702e09$1_1@dnews> X-Trace: dnews 1013984777 203.109.148.190 (17 Feb 2002 14:26:17 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!news2.euro.net!news7.euro.net!newsfeed.freenet.de!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews