2

I have a view that is incorporated in another view call.

CREATE VIEW view_A AS SELECT .... FROM table_Gamma

CREATE VIEW view_B AS SELECT .... FROM view_A

In Android 5.0 it's printing out this error

E/SQLiteLog (284) automatic index on view_A(Col1)

Since you can't index views in Sqlite, it seems to be thinking view_A is a table, and that it can be indexed, when it's a view.

Note I also tried creating an index on table_Gamma, it did not help.

You can turn off auto-indexing using this Pragma call

PRAGMA automatic_index = off;

SQLite Database gives warning automatic index on <table_name>(column) After upgrading Android L

But it seems to be impractical in that it needs to be called every time SQLiteOpenHelper is used.

Is this a common practice, or is there another place to call to turn off automatic_index?

Community
  • 1
  • 1
pt123
  • 2,146
  • 1
  • 32
  • 57

2 Answers2

2

from this thread Foreign key constraints in Android using SQLite? on Delete cascade

it seems the better way is to override the onOpen method in SQLiteOpenHelper

@Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
        if (!db.isReadOnly()) {
            db.execSQL("PRAGMA automatic_index = off;");
        }
    }

I still feel it's a bug that Sqlite3 can't differentiate a view withing a view, when calling this error.

Community
  • 1
  • 1
pt123
  • 2,146
  • 1
  • 32
  • 57
  • Looking at the query plan if you turn automatic index off it does not use the underlying index. At the same time if you sure a table instead of view, it uses existing index correctly. Sounds like a bug to me. – root Jan 11 '17 at 12:41
0

There is no error. (The only error is that Android labels this warning as an error.)

This message indicates that an automatic index was created successfully.

A table can be used multiple times in a query, so it gets shown with the name under which it is actually used in query, even if this happens to be a view name.

CL.
  • 173,858
  • 17
  • 217
  • 259