Fixed
Status Update
Comments
[Deleted User] <[Deleted User]> #2
hmm it should not ask for a transaction. In fact, we don't want a transaction.
Can you show us that error?
yaraki@, i think we should check if we are already in a transaction before sending vacuum and if so, print a warning and skip vacuum.
Can you show us that error?
yaraki@, i think we should check if we are already in a transaction before sending vacuum and if so, print a warning and skip vacuum.
ab...@gmail.com <ab...@gmail.com> #3
Hello, when I call clearAllTables Room throws an error saying that I should start a Transaction. So I did that, and now the method throws that VACUUM cannot run inside a Transaction.
yb...@google.com <yb...@google.com> #4
Can you share the error message saying that a Transaction is needed?
ko...@gmail.com <ko...@gmail.com> #5
I catch the exception again. As you can see below. but I have see that that error only happen when I run clearAllTables in Main Thread.
I know that we should not do that, and when I run clearAllTables in a background thread it runs without errors.
So I believe that the exception gives a wrong message.
04-02 07:04:06.133 4197-4197/br.com.mobilesales.influxlexical E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.mobilesales.influxlexical, PID: 4197
java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:915)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:398)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:524)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.endTransaction(FrameworkSQLiteDatabase.java:90)
at android.arch.persistence.room.RoomDatabase.endTransaction(RoomDatabase.java:261)
at br.com.mobilesales.influxlexical.data.source.local.AppDatabase_Impl.clearAllTables(AppDatabase_Impl.java:355)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication$override.logoffUser(InfluxLexicalApplication.java:154)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication$override.access$dispatch(InfluxLexicalApplication.java)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication.logoffUser(InfluxLexicalApplication.java)
at br.com.mobilesales.influxlexical.MainActivity.onOptionsItemSelected(MainActivity.kt:247)
at android.app.Activity.onMenuItemSelected(Activity.java:3204)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:380)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:63)
at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:203)
at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:780)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:963)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:624)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:150)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I know that we should not do that, and when I run clearAllTables in a background thread it runs without errors.
So I believe that the exception gives a wrong message.
04-02 07:04:06.133 4197-4197/br.com.mobilesales.influxlexical E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.mobilesales.influxlexical, PID: 4197
java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:915)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:398)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:524)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.endTransaction(FrameworkSQLiteDatabase.java:90)
at android.arch.persistence.room.RoomDatabase.endTransaction(RoomDatabase.java:261)
at br.com.mobilesales.influxlexical.data.source.local.AppDatabase_Impl.clearAllTables(AppDatabase_Impl.java:355)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication$override.logoffUser(InfluxLexicalApplication.java:154)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication$override.access$dispatch(InfluxLexicalApplication.java)
at br.com.mobilesales.influxlexical.InfluxLexicalApplication.logoffUser(InfluxLexicalApplication.java)
at br.com.mobilesales.influxlexical.MainActivity.onOptionsItemSelected(MainActivity.kt:247)
at android.app.Activity.onMenuItemSelected(Activity.java:3204)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:380)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:108)
at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:63)
at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:203)
at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:780)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:963)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:624)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:150)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
te...@gmail.com <te...@gmail.com> #6
clearAllTables is not supposed to be run in a main thread. It is annotated with @WorkerThread, and you should always run it in a background thread.
sy...@gmail.com <sy...@gmail.com> #7
This is needed for asserting query execution and increasing the speed of adoption of the framework. Please prioritize higher as simple as it is.
da...@gmail.com <da...@gmail.com> #8
Please, it would be very helpful for developers to be able to debug room operations in an easy way.
mi...@pharos-solutions.de <mi...@pharos-solutions.de> #9
Please, it would be very helpful for a more complicated erd, prioritize higher as soon as possible.
yb...@google.com <yb...@google.com> #10
this looks like a perfect candidate for external contribution.
It is also probably better to implement this in the androidx.sqlite package instead to ensure all queries are covered.
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #11
Project: platform/frameworks/support
Branch: androidx-master-dev
commit ab6d205c0217a0ed5c170bf6ceadb20422947699
Author: Elif Bilgin <elifbilgin@google.com>
Date: Tue Nov 17 13:50:26 2020
Implementing functionality for a general callback function for SQLite queries. If possible, bind arguments are provided to the callback in addition to the SQLite query statement. This callback may be used for logging executed queries, in which case it is recommended to use an immediate executor.
This CL will be followed up by a CL resolving b/174478034 .
Test: Tests have been added QueryInterceptorTest.kt
Relnote: Add query callback feature to Room.
Bug: 74877608
Change-Id: Iaa513e39115f0c9c68359774fa70e1d3dd022c39
A room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/QueryInterceptorTest.kt
M room/runtime/api/current.txt
M room/runtime/api/public_plus_experimental_current.txt
M room/runtime/api/restricted_current.txt
A room/runtime/src/main/java/androidx/room/QueryInterceptorDatabase.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorOpenHelper.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorOpenHelperFactory.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorStatement.java
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
https://android-review.googlesource.com/1502194
Branch: androidx-master-dev
commit ab6d205c0217a0ed5c170bf6ceadb20422947699
Author: Elif Bilgin <elifbilgin@google.com>
Date: Tue Nov 17 13:50:26 2020
Implementing functionality for a general callback function for SQLite queries. If possible, bind arguments are provided to the callback in addition to the SQLite query statement. This callback may be used for logging executed queries, in which case it is recommended to use an immediate executor.
This CL will be followed up by a CL resolving
Test: Tests have been added QueryInterceptorTest.kt
Relnote: Add query callback feature to Room.
Bug: 74877608
Change-Id: Iaa513e39115f0c9c68359774fa70e1d3dd022c39
A room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/QueryInterceptorTest.kt
M room/runtime/api/current.txt
M room/runtime/api/public_plus_experimental_current.txt
M room/runtime/api/restricted_current.txt
A room/runtime/src/main/java/androidx/room/QueryInterceptorDatabase.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorOpenHelper.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorOpenHelperFactory.java
A room/runtime/src/main/java/androidx/room/QueryInterceptorStatement.java
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
Description
Version used: 1.1.0-alpha3
Currently there is no built-in way to debug failed queries and there isn't much information logged in LogCat by Room either.
It would be extremely helpful (especially when debugging complex queries) if RoomDatabase had a method to set a debugging flag to receive verbose information about queries being executed.