Project

General

Profile

« Previous | Next » 

Revision 3526

sql_gen.py: RowExcIgnore.to_str(): Moved SQL comment explaining the use of an EXCEPTION block for each individual row to Python code to avoid cluttering the logged SQL code

View differences:

lib/sql_gen.py
684 684
        if self.cols == None: row_vars = [self.row_var]
685 685
        else: row_vars = [Col(c.name, self.row_var) for c in self.cols]
686 686
        
687
        # Need an EXCEPTION block for each individual row because "When an error
688
        # is caught by an EXCEPTION clause, [...] all changes to persistent
689
        # database state within the block are rolled back."
690
        # This is unfortunate because "A block containing an EXCEPTION clause is
691
        # significantly more expensive to enter and exit than a block without
692
        # one."
693
        # (http://www.postgresql.org/docs/8.3/static/\
694
        # plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING)
687 695
        str_ = '''\
688 696
DECLARE
689 697
    '''+self.row_var.to_str(db)+''' '''+self.row_type.to_str(db)+''';
690 698
BEGIN
691
    /* Need an EXCEPTION block for each individual row because "When
692
    an error is caught by an EXCEPTION clause, [...] all changes to
693
    persistent database state within the block are rolled back."
694
    This is unfortunate because "A block containing an EXCEPTION
695
    clause is significantly more expensive to enter and exit than a
696
    block without one."
697
    (http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html\
698
#PLPGSQL-ERROR-TRAPPING)
699
    */
700 699
    FOR '''+(', '.join((v.to_str(db) for v in row_vars)))+''' IN
701 700
'''+strings.indent(self.select_query.to_str(db), 2)+'''\
702 701
    LOOP

Also available in: Unified diff