Subject Firebird 2.0 - SchemaCache problem - Patch
Author Thomas Steinmaurer
Hi all,

my reported TIB_Connection.SchemaCache problem with Firebird 2.0 is easy
to fix. The failing system table queries are in IB_Schema.pas:

procedure SchemaIndexInfo( Cn: TIB_Connection;
Tr: TIB_Transaction;
System: boolean;
Names: TStrings;
RelationName: string );

and

procedure SchemaForeignKeyInfo( Cn: TIB_Connection;
Tr: TIB_Transaction;
RelationName: string;
TargetRelationNames: boolean;
ForeignKeys: TStrings );


I've replaced parts of the SQL statement like that:

1) In the procedure SchemaIndexInfo

Instead of the lines:

SQL.Add( 'SELECT RDB$INDICES.RDB$INDEX_NAME' );
SQL.Add( ' , RDB$INDICES.RDB$RELATION_NAME' );

Use:

SQL.Add( 'SELECT I.RDB$INDEX_NAME' );
SQL.Add( ' , I.RDB$RELATION_NAME' );


2) In the procedure SchemaForeignKeyInfo

Instead of the lines:

SQL.Add( 'SELECT RDB$INDEX_SEGMENTS.RDB$FIELD_NAME' );
SQL.Add( ' , RDB$INDICES.RDB$RELATION_NAME' );

Use:

SQL.Add( 'SELECT S.RDB$FIELD_NAME' );
SQL.Add( ' , I.RDB$RELATION_NAME' );


And, to make it even cleaner, instead of the line:

SQL.Add( 'WHERE RDB$CONSTRAINT_TYPE = ''FOREIGN KEY''' );

Use:

SQL.Add( 'WHERE C.RDB$CONSTRAINT_TYPE = ''FOREIGN KEY''' );


Not sure if there are others failing as well, but the one above
obviously make troubles.



--
HTH,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2 (NEW!)
Upscene Productions
http://www.upscene.com