def is_index_valid(cursor, iname):
    """Returns True iff the index is valid. Don't call on non-existant index"""
    cursor.execute(
        'SELECT i.indisvalid FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_catalog.pg_index i WHERE i.indexrelid = c.oid AND c.relnamespace = n.oid and c.relname = %s;'
        , (iname,))
    result = cursor.fetchone()[0]
    return result
