0

I see the following error when retrieving data from sqldelight database, and it only happens if the retrieved data is relatively big.

android.database.sqlite.SQLiteException · unknown error (code 0 SQLITE_OK): Native could not read blob slot CursorWindow.java:-2 android.database.CursorWindow.nativeGetBlob CursorWindow.java:434 android.database.CursorWindow.getBlob AbstractWindowedCursor.java:47 android.database.AbstractWindowedCursor.getBlob AndroidCursor:276 com.squareup.sqldelight.android.AndroidCursor.getBytes
MessageQueriesImpl:3454 com.myapp.data.data.MessageQueriesImpl$select_all$1.invoke MessageQueriesImpl:3435 com.myapp.data.data.MessageQueriesImpl$select_all$1.invoke Query:135 java.lang.NullPointerException at com.myapp.data.data.MessageQueriesImpl$select_all$1.invoke(SourceFile:3) com.squareup.sqldelight.Query.executeAsList RxQuery:74 com.squareup.sqldelight.runtime.rx.RxQuery.mapToList$lambda-3 RxQuery com.squareup.sqldelight.runtime.rx.RxQuery.$r8$lambda$JBLCjGO0wKFvZfSQQB_6IJwBoOw Unknown:2 com.squareup.sqldelight.runtime.rx.c.apply ObservableMap:57 io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext
ObservableObserveOn:201 io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal
ObservableObserveOn:255 io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run
ScheduledRunnable:66 io.reactivex.internal.schedulers.ScheduledRunnable.run
ScheduledRunnable:57 io.reactivex.internal.schedulers.ScheduledRunnable.call
FutureTask.java:266 java.util.concurrent.FutureTask.run
ScheduledThreadPoolExecutor.java:301 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run
ThreadPoolExecutor.java:1167 java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:641 java.util.concurrent.ThreadPoolExecutor$Worker.run Thread.java:923 java.lang.Thread.run

I don’t know what would make the database layer return null for a non-null column type but maybe one theory is that the native SQLite layer is running out of memory and “failing” by returning null even though the Kotlin side of things treat the value as a non-null type, resulting in the NullPointerException.

.sq

select_all: SELECT * FROM message_view;

CREATE VIEW message_view AS
SELECT
M.id AS message_id,
...
MSS.last_message_seen_id AS message_seen_state_last_message_seen_id,
MP.photos AS message_person_photos,
FROM `message` M
LEFT JOIN message_person MP ON M.person_id = MP.id
...
LEFT JOIN message_seen_state MSS ON M.id = MSS.message_id;


CREATE TABLE `message` (
    id TEXT NOT NULL PRIMARY KEY,
    creation_date INTEGER AS DateTime NOT NULL,
    last_activity_date INTEGER AS DateTime NOT NULL,
    person_id TEXT,
    type TEXT AS MessageType NOT NULL DEFAULT 'CORE',
    ...
    FOREIGN KEY (person_id) REFERENCES message_person(id),
);

If the issue is that the query hits the operation size limit, how can we bypass this issue?

Levon Petrosyan
  • 8,815
  • 8
  • 54
  • 65

1 Answers1

1

Suspected there might be something wrong with your SQL query, but it seems alright

According to this There is a 1MB limit per operation. So I guess that's the memory limit for one SQL query. The limit is due to the SQLite API interacting with sqlite out-of-process over the Binder/Parcel IPC system. The same limit applies for values within a Bundle (Intent extras, for instance).

you might also find some data here ?

JustSightseeing
  • 1,460
  • 3
  • 17
  • 37