Project

General

Profile

« Previous | Next » 

Revision 1852

sql.py: index_cols(): Cache return values in db.index_cols

View differences:

lib/sql.py
190 190
    constraint or a UNIQUE index, use this function.'''
191 191
    check_name(table)
192 192
    check_name(index)
193
    module = util.root_module(db.db)
194
    if module == 'psycopg2':
195
        return list(values(run_query(db, '''\
193
    lookup = (table, index)
194
    if lookup not in db.index_cols:
195
        module = util.root_module(db.db)
196
        if module == 'psycopg2':
197
            db.index_cols[lookup] = list(values(run_query(db, '''\
196 198
SELECT attname
197 199
FROM
198 200
(
......
223 225
) s
224 226
ORDER BY attnum
225 227
''',
226
            {'table': table, 'index': index})))
227
    else: raise NotImplementedError("Can't list index columns for "+module+
228
        ' database')
228
                {'table': table, 'index': index})))
229
        else: raise NotImplementedError("Can't list index columns for "+module+
230
            ' database')
231
    return db.index_cols[lookup]
229 232

  
230 233
def constraint_cols(db, table, constraint):
231 234
    check_name(table)

Also available in: Unified diff