Subject RDB$CONSTRAINT_TYPE returning Null for Unique index
Author Werner F. Bruhin
I am having a go at creating a FB backend for Django, it is a little
over my head but by reviewing the other backends I think I have a chance
of getting there.

I am running into a problem that RDB$CONSTRAINT_TYPE returns Null for a
Unique index with the following query.

Can anyone point me in the right direction on how to get all the indexes
for a table (need to now if it is the primary key index or if it is a
unique index).

Werner

RDB$FIELD_NAME, i2.RDB$RELATION_NAME, s2.RDB$FIELD_NAME,
rc.RDB$CONSTRAINT_TYPE
FROM RDB$INDEX_SEGMENTS s
LEFT JOIN RDB$INDICES i ON i.RDB$INDEX_NAME =
s.RDB$INDEX_NAME
LEFT JOIN RDB$RELATION_CONSTRAINTS rc ON
rc.RDB$INDEX_NAME = s.RDB$INDEX_NAME
LEFT JOIN RDB$REF_CONSTRAINTS refc ON
rc.RDB$CONSTRAINT_NAME = refc.RDB$CONSTRAINT_NAME
LEFT JOIN RDB$RELATION_CONSTRAINTS rc2 ON
rc2.RDB$CONSTRAINT_NAME = refc.RDB$CONST_NAME_UQ
LEFT JOIN RDB$INDICES i2 ON i2.RDB$INDEX_NAME =
rc2.RDB$INDEX_NAME
LEFT JOIN RDB$INDEX_SEGMENTS s2 ON
i2.RDB$INDEX_NAME = s2.RDB$INDEX_NAME
WHERE i.RDB$RELATION_NAME='tablename'
ORDER BY s.RDB$FIELD_POSITION;