Project

General

Profile

« Previous | Next » 

Revision 2309

sql.py: put_table(): Debug-log each caught exception

View differences:

sql.py
761 761
        return mk_select(db, insert_joins, cols, conds, distinct_on,
762 762
            limit=limit, start=start, default_table=in_tables0)
763 763
    
764
    def log_exc(e):
765
        db.log_debug('Caught exception: '+exc.str_(e, first_line_only=True))
764 766
    def log_ignore(in_col, value):
765 767
        db.log_debug('Ignoring rows with '+in_col+' = '+value)
766 768
    
......
791 793
                *mk_main_select(mapping.values()), returning=returning,
792 794
                into_ref=into_ref, recover=True)
793 795
        except DuplicateKeyException, e:
796
            log_exc(e)
797
            
794 798
            old_join_cols = join_cols.copy()
795 799
            join_cols.update(util.dict_subset_right_join(mapping, e.cols))
796 800
            db.log_debug('Ignoring existing rows, comparing on '+str(join_cols))
797 801
            assert join_cols != old_join_cols # avoid infinite loops
802
            
798 803
            # rerun loop with additional constraints
799 804
        except NullValueException, e:
805
            log_exc(e)
806
            
800 807
            out_col, = e.cols
801 808
            try: in_col = mapping[out_col]
802 809
            except KeyError: # no mapping for missing col, so every row invalid
......
809 816
                conds[in_col] = sql_gen.CompareCond(None, '!=')
810 817
                # rerun loop with additional constraints
811 818
        except FunctionValueException, e:
819
            log_exc(e)
820
            
812 821
            assert e.name == sql_gen.unescape_table(out_table)
813 822
            out_col = 'value' # assume function param was named "value"
814 823
            in_col = mapping[out_col]

Also available in: Unified diff