Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.6

Bug #13977 Cannot add UNIQUE attribute to an existing index
Submitted: 2008-05-24 11:34 UTC
From: hschletz Assigned: ifeghali
Status: Closed Package: MDB2_Schema (version 0.8.2)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 38 + 39 = ?

 [2008-05-24 11:34 UTC] hschletz (Holger Schletz)
Description: ------------ alterDatabaseIndexes() fails to add a UNIQUE attribute to an existing non-unique index. This happens because it makes the false assumption that if the new index definition has the 'unique' attribute (making it a constraint in MDB2 Terms), the existing index would we a constraint too and calls dropConstraint() even when dropIndex() would be the correct choice. The attached patch checks whether the existing index (if present) is actually a constraint and takes the appropriate action on it. Test script: --------------- Existing index was created with this definition: <index> <name>foo_bar</name> <field> <name>bar</name> </field> </index> New definition is: <index> <name>foo_bar</name> <unique>true</unique> <field> <name>bar</name> </field> </index> Expected result: ---------------- updateDatabase() turns existing index foo_bar_idx into a UNIQUE constraint. Actual result: -------------- DBMS (tested with PostgreSQL) aborts with an error because ALTER TABLE ... DROP CONSTRAINT is called on a nonexistent constraint.


 [2008-11-15 19:34 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.