Eli Mesika has posted comments on this change.

Change subject: core : DB FK validation
......................................................................


Patch Set 5: (4 inline comments)

....................................................
File backend/manager/dbscripts/common_sp.sql
Line 564:     where table_schema not in ('pg_catalog','information_schema') and 
table_type = 'BASE TABLE') AND
Line 565:         r.confrelid = c.oid AND
Line 566:         r.contype = 'f' AND
Line 567:         c2.oid = r.conrelid AND
Line 568:         pg_get_constraintdef(r.oid) not ilike '%ON DELETE SET %'
In any case that there can be a child record while the parent record is 
removed, we are not handling that , remember that this utility is targeted to 
solve inconsistent data insertion forced by breaking DB constrains
Line 569:     ORDER BY  table_name;
Line 570: 
Line 571: BEGIN
Line 572:     OPEN v_cur;


Line 565:         r.confrelid = c.oid AND
Line 566:         r.contype = 'f' AND
Line 567:         c2.oid = r.conrelid AND
Line 568:         pg_get_constraintdef(r.oid) not ilike '%ON DELETE SET %'
Line 569:     ORDER BY  table_name;
Done
Line 570: 
Line 571: BEGIN
Line 572:     OPEN v_cur;
Line 573:     LOOP


Line 576:         IF (v_fix_it) THEN
Line 577:             v_sql := 'delete from ' || v_record.fk_table_name ||
Line 578:                       ' where ' || v_record.fk_col || ' not in 
(select ' ||
Line 579:                       v_record.table_col || ' from ' || 
v_record.table_name || ');';
Line 580:             v_msg := 'Fixing ' ||  v_record.fk_table_name || 
v_record.fk_col;
The EXECUTE below will do each sql in this loop in a separate transaction, so , 
we have no problem with that and don't need any flag
Line 581:         ELSE
Line 582:             v_sql := 'select ' || v_record.fk_col || ' from ' || 
v_record.fk_table_name ||
Line 583:                       ' where ' || v_record.fk_col || ' not in 
(select ' ||
Line 584:                       v_record.table_col || ' from ' || 
v_record.table_name || ');';


....................................................
Commit Message
Line 6: 
Line 7: core : DB FK validation
Line 8: 
Line 9:  The purpose of this utility is to find inconsistent data that violates
Line 10:  FK(Forign Keys), display it and enable to remove it
Done
Line 11:  Only support may access this utility with care
Line 12:  It is mandatory to run this utility on the original database before a
Line 13:  backup of the DB is taken for later
Line 14:  restore purpose, since if the database is backed up with the corrupted


--
To view, visit http://gerrit.ovirt.org/10248
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibe54bca7a832c1c358a5e8c7214e7825cb9e4fc3
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Michael Kublin <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to