Eli Mesika has uploaded a new change for review. Change subject: core: DB Adding missing check to fix... ......................................................................
core: DB Adding missing check to fix... DB Adding missing check to fix duplicate key violation Checking if key exists before attempt to add a record to disks table. This fixes an attempt to insert duplicate key to the disks table. Change-Id: Ia1f8befcaad0e20d7259980cb0e5f2e116964245 Signed-off-by: Eli Mesika <[email protected]> --- M backend/manager/dbscripts/upgrade/03_01_0070_populate_disks_table.sql 1 file changed, 10 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/10701/1 diff --git a/backend/manager/dbscripts/upgrade/03_01_0070_populate_disks_table.sql b/backend/manager/dbscripts/upgrade/03_01_0070_populate_disks_table.sql index df8f4d7..3d751af 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0070_populate_disks_table.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0070_populate_disks_table.sql @@ -16,8 +16,9 @@ JOIN image_vm_map ivm ON i.image_guid = ivm.image_id WHERE active = TRUE) LOOP - INSERT - INTO disks + IF NOT EXISTS (SELECT disk_id from disks WHERE disk_id = cur.image_group_id) THEN + INSERT + INTO disks (disk_id, status, internal_drive_mapping, @@ -26,7 +27,7 @@ disk_interface, wipe_after_delete, propagate_errors) - VALUES + VALUES (cur.image_group_id, CASE WHEN cur.imagestatus = 1 THEN 'OK' WHEN cur.imagestatus = 2 THEN 'LOCKED' @@ -51,7 +52,7 @@ CASE WHEN cur.propagate_errors = 1 THEN 'On' ELSE 'Off' END); - + END IF; END LOOP; -- Populate Disks table from image_templates table. @@ -62,8 +63,9 @@ JOIN vm_template_image_map vtim USING (it_guid) JOIN images i ON it.it_guid = i.image_guid) LOOP - INSERT - INTO disks + IF NOT EXISTS (SELECT disk_id from disks WHERE disk_id = cur.image_group_id) THEN + INSERT + INTO disks (disk_id, status, internal_drive_mapping, @@ -72,7 +74,7 @@ disk_interface, wipe_after_delete, propagate_errors) - VALUES + VALUES (cur.image_group_id, CASE WHEN cur.imagestatus = 1 THEN 'OK' WHEN cur.imagestatus = 2 THEN 'LOCKED' @@ -97,7 +99,7 @@ CASE WHEN cur.propagate_errors = 1 THEN 'On' ELSE 'Off' END); - + END IF; END LOOP; END; $function$ -- To view, visit http://gerrit.ovirt.org/10701 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia1f8befcaad0e20d7259980cb0e5f2e116964245 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
