Revision 5664
Added by Aaron Marcuse-Kubitza about 12 years ago
schemas/vegbien.sql | ||
---|---|---|
669 | 669 |
WHERE descendant_id = parent_id_ |
670 | 670 |
); |
671 | 671 |
descendant_id_ integer; |
672 |
ancestor_id_ taxonlabel_relationship.ancestor_id%TYPE; |
|
672 | 673 |
BEGIN |
673 | 674 |
FOR descendant_id_ IN -- also includes self |
674 | 675 |
SELECT descendant_id |
... | ... | |
682 | 683 |
; |
683 | 684 |
|
684 | 685 |
-- Add new parent's ancestors |
685 |
INSERT INTO taxonlabel_relationship |
|
686 |
(descendant_id, ancestor_id) |
|
687 |
SELECT descendant_id_, unnest(new_ancestors) |
|
688 |
; |
|
686 |
FOR ancestor_id_ IN |
|
687 |
SELECT unnest(new_ancestors) |
|
688 |
LOOP |
|
689 |
BEGIN |
|
690 |
INSERT INTO taxonlabel_relationship |
|
691 |
(descendant_id, ancestor_id) |
|
692 |
SELECT descendant_id_, ancestor_id_ |
|
693 |
; |
|
694 |
EXCEPTION |
|
695 |
WHEN unique_violation THEN |
|
696 |
RAISE WARNING '%', SQLERRM; |
|
697 |
END; |
|
698 |
END LOOP; |
|
689 | 699 |
END LOOP; |
690 | 700 |
END; |
691 | 701 |
END IF; |
Also available in: Unified diff
schemas/vegbien.sql: taxonlabel_update_ancestors(): Adding new parent's ancestors: Change unique_violations to warnings so they don't abort the import. unique_violations should never happen unless there are cycles of two or mode nodes, but they seem to be happening nevertheless, so this will provide a workaround to that problem.