Project

General

Profile

« Previous | Next » 

Revision 3033

sql.py: mk_insert_select(): INSERT IGNORE: Moved FETCH FROM cursor outside EXCEPTION block since only the insert needs to have unique_violations ignored

View differences:

sql.py
683 683
#PLPGSQL-ERROR-TRAPPING)
684 684
    */
685 685
    WHILE true LOOP
686
        FETCH FROM cur INTO \
687
'''+(', '.join((c.to_str(db) for c in row)))+''';
688
        EXIT WHEN NOT FOUND;
689
        
686 690
        BEGIN
687
            FETCH FROM cur INTO \
688
'''+(', '.join((c.to_str(db) for c in row)))+''';
689
            EXIT WHEN NOT FOUND;
690
            
691 691
            RETURN QUERY
692 692
'''+mk_insert(sql_gen.Values(row).to_str(db))+'''
693 693
;
694 694
        EXCEPTION
695
            /* Note that cursor stays at current position in spite of automatic
696
            ROLLBACK to before EXCEPTION block: "If a previously opened cursor
697
            is affected by a FETCH command inside a savepoint that is later
698
            rolled back, the cursor position remains at the position that FETCH
699
            left it pointing to (that is, FETCH is not rolled back)."
700
            (http://www.postgresql.org/docs/8.3/static/sql-rollback-to.html)
701
            */
702 695
            WHEN unique_violation THEN NULL; -- continue to next row
703 696
        END;
704 697
    END LOOP;

Also available in: Unified diff