![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The information_schema.referential_constraints retuns wrong data because there is an incomplete joining condition in the WHERE clause. [ these two conditions need to be added: ] AND con.contype = 'f' AND con.confrelid = pkc.conrelid |
#3
| ||||
| ||||
|
|
Tom Lane writes: Another problem is that the view will fail to list FK constraints at all if it cannot identify a matching unique constraint. If you want information under those conditions, you're looking at the wrong view. table_constraints gives you general information about constraints. |
|
Which there may not be (the backend code for creating an FK checks for a matching unique index, quite a different animal). I think that should be changed. |
|
A more robust way to handle things would be to make use of pg_depend to I've used pg_depend for some other views, but that entails problems as well, for example, because they don't track system tables. |
|
Another question is whether to force an initdb after making this change. If we don't, existing beta testers may continue to use the incorrect view definition. I think we will have to. |
#4
| |||
| |||
|
|
Tom Lane writes: No, because that would entail a genuine loss of capability: FK constraints couldn't be built using indexes that were made by CREATE UNIQUE INDEX rather than through the unique/pk constraint syntax. In particular this would mean that non-btree indexes could not be used. But that means the deficiency is elsewhere, namely that you cannot build non-btree indexes for primary key or unique constraints. |
|
Isn't the whole unique index thing a dead end anyway? How are we ever going to get deferrable unique constraints that way? |
![]() |
| Thread Tools | |
| Display Modes | |
| |