Project

General

Profile

« Previous | Next » 

Revision 3467

Autogenerated SQL code: Use new strings.indent() where needed

View differences:

sql_gen.py
486 486
    def to_str(self, db, body):
487 487
        body = as_Code(body)
488 488
        
489
        if self.handler != None: handler_str = '\n'+self.handler.to_str(db)
489
        if self.handler != None:
490
            handler_str = '\n'+strings.indent(self.handler.to_str(db), 2)
490 491
        else: handler_str = ' NULL;\n'
491 492
        
492 493
        str_ = '''\
493 494
BEGIN
494
'''+body.to_str(db)+'''\
495
'''+strings.indent(body.to_str(db))+'''\
495 496
EXCEPTION
496 497
    WHEN '''+self.exc+''' THEN'''+handler_str+'''\
497 498
END;\
......
526 527
DECLARE
527 528
    '''+self.row_var.to_str(db)+''' '''+self.row_type+''';
528 529
BEGIN
529
    /* Need an EXCEPTION block for each individual row because "When an error is
530
    caught by an EXCEPTION clause, [...] all changes to persistent database
531
    state within the block are rolled back."
532
    This is unfortunate because "A block containing an EXCEPTION clause is
533
    significantly more expensive to enter and exit than a block without one."
530
    /* Need an EXCEPTION block for each individual row because "When
531
    an error is caught by an EXCEPTION clause, [...] all changes to
532
    persistent database state within the block are rolled back."
533
    This is unfortunate because "A block containing an EXCEPTION
534
    clause is significantly more expensive to enter and exit than a
535
    block without one."
534 536
    (http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html\
535 537
#PLPGSQL-ERROR-TRAPPING)
536 538
    */
537 539
    FOR '''+(', '.join((v.to_str(db) for v in row_vars)))+''' IN
538
'''+self.select_query.to_str(db)+'''
540
'''+strings.indent(self.select_query.to_str(db), 2)+'''\
539 541
    LOOP
540
'''+self.exc_handler.to_str(db, self.with_row)+'''
542
'''+strings.indent(self.exc_handler.to_str(db, self.with_row), 2)+'''\
541 543
    END LOOP;
542 544
END;\
543 545
'''

Also available in: Unified diff