Project

General

Profile

« Previous | Next » 

Revision 2916

sql.py: Use new DbConn.debug_temp config option to control whether temporary objects should instead be permanent

View differences:

lib/sql_gen.py
308 308
Function = Table
309 309
as_Function = as_Table
310 310

  
311
def TempFunction(name, autocommit):
311
def TempFunction(name, debug_temp):
312 312
    schema = None
313
    if not autocommit: schema = 'pg_temp'
313
    if not debug_temp: schema = 'pg_temp'
314 314
    return Function(name, schema)
315 315

  
316 316
class InternalFunction(CustomCode): pass
lib/sql.py
154 154
        @param debug_temp Whether temporary objects should instead be permanent.
155 155
            This assists in debugging the internal objects used by the program.
156 156
        '''
157
        if debug_temp: autocommit = True
158
        
157 159
        self.db_config = db_config
158 160
        self.autocommit = autocommit
159 161
        self.caching = caching
......
482 484
    kw_args['recover'] = True
483 485
    kw_args.setdefault('log_ignore_excs', (DuplicateTableException,))
484 486
    
485
    temp = not db.autocommit # tables are permanent in autocommit mode
487
    temp = not db.debug_temp # tables are permanent in debug_temp mode
486 488
    # "temporary tables cannot specify a schema name", so remove schema
487 489
    if temp: into.schema = None
488 490
    
......
630 632
        return_type = 'SETOF '+returning.to_str(db)+'%TYPE'
631 633
        while True:
632 634
            try:
633
                function = sql_gen.TempFunction(function_name, db.autocommit)
635
                function = sql_gen.TempFunction(function_name, db.debug_temp)
634 636
                
635 637
                function_query = '''\
636 638
CREATE FUNCTION '''+function.to_str(db)+'''()
......
801 803
    errors_table = sql_gen.as_Table(errors_table)
802 804
    srcs = map(sql_gen.to_name_only_col, col.srcs)
803 805
    function_name = str(sql_gen.FunctionCall(type_, *srcs))
804
    function = sql_gen.TempFunction(function_name, db.autocommit)
806
    function = sql_gen.TempFunction(function_name, db.debug_temp)
805 807
    
806 808
    while True:
807 809
        # Create function definition
bin/map
133 133
    def connect_db(db_config):
134 134
        log('Connecting to '+sql.db_config_str(db_config))
135 135
        return sql.connect(db_config, caching=cache_sql,
136
            autocommit=verbosity > 3 and commit, log_debug=log_debug)
136
            debug_temp=verbosity > 3 and commit, log_debug=log_debug)
137 137
    
138 138
    if end != None: end_str = str(end-1) # end is one past the last #
139 139
    else: end_str = 'end'

Also available in: Unified diff