room/runtime/src/main/java/androidx/room/util/TableInfo.java
@Nullable
    private static Index readIndex(SupportSQLiteDatabase database, String name, boolean unique) {
        Cursor cursor = database.query("PRAGMA index_xinfo(`" + name + "`)");
        try {
            final int seqnoColumnIndex = cursor.getColumnIndex("seqno");
            final int cidColumnIndex = cursor.getColumnIndex("cid");
            final int nameColumnIndex = cursor.getColumnIndex("name");
            if (seqnoColumnIndex == -1 || cidColumnIndex == -1 || nameColumnIndex == -1) {
                // we cannot read them so better not validate any index.
                return null;
            }
            final TreeMap<Integer, String> results = new TreeMap<>();

            while (cursor.moveToNext()) {
                int cid = cursor.getInt(cidColumnIndex);
                if (cid < 0) {
                    // Ignore SQLite row ID
                    continue;
                }
                int seq = cursor.getInt(seqnoColumnIndex);
                String columnName = cursor.getString(nameColumnIndex);
                results.put(seq, columnName);
            }
            final List<String> columns = new ArrayList<>(results.size());
            columns.addAll(results.values());
            return new Index(name, unique, columns);
        } finally {
            cursor.close();
        }
    }
/**
     * @return null if we cannot read the index due to older sqlite implementations.
     */
@return null if we cannot read the index due to older sqlite implementations.
@return null if we cannot read the index due to older sqlite implementations .
@Nullable
    private static Index readIndex(SupportSQLiteDatabase database, String name, boolean unique) {
        Cursor cursor = database.query("PRAGMA index_xinfo(`" + name + "`)");
        try {
            final int seqnoColumnIndex = cursor.getColumnIndex("seqno");
            final int cidColumnIndex = cursor.getColumnIndex("cid");
            final int nameColumnIndex = cursor.getColumnIndex("name");
            if (seqnoColumnIndex == -1 || cidColumnIndex == -1 || nameColumnIndex == -1) {
                return null;
            }
            final TreeMap<Integer, String> results = new TreeMap<>();
            while (cursor.moveToNext()) {
                int cid = cursor.getInt(cidColumnIndex);
                if (cid < 0) {
                    continue;
                }
                int seq = cursor.getInt(seqnoColumnIndex);
                String columnName = cursor.getString(nameColumnIndex);
                results.put(seq, columnName);
            }
            final List<String> columns = new ArrayList<>(results.size());
            columns.addAll(results.values());
            return new Index(name, unique, columns);
        } finally {
            cursor.close();
        }
    }
@ Nullable private static Index readIndex ( SupportSQLiteDatabase database , String name , boolean unique ) { Cursor cursor = database . query ( "PRAGMA index_xinfo(`" + name + "`)" ) ; try { final int seqnoColumnIndex = cursor . getColumnIndex ( "seqno" ) ; final int cidColumnIndex = cursor . getColumnIndex ( "cid" ) ; final int nameColumnIndex = cursor . getColumnIndex ( "name" ) ; if ( seqnoColumnIndex == - 1 || cidColumnIndex == - 1 || nameColumnIndex == - 1 ) { return null ; } final TreeMap < Integer , String > results = new TreeMap < > ( ) ; while ( cursor . moveToNext ( ) ) { int cid = cursor . getInt ( cidColumnIndex ) ; if ( cid < 0 ) { continue ; } int seq = cursor . getInt ( seqnoColumnIndex ) ; String columnName = cursor . getString ( nameColumnIndex ) ; results . put ( seq , columnName ) ; } final List < String > columns = new ArrayList < > ( results . size ( ) ) ; columns . addAll ( results . values ( ) ) ; return new Index ( name , unique , columns ) ; } finally { cursor . close ( ) ; } }
@return null if we cannot read the index due to older sqlite implementations.
@return null if we cannot read the index due to older sqlite implementations .
// we cannot read them so better not validate any index. // Ignore SQLite row ID