Closed thaden0 closed 9 years ago
And a work around; Storing the image in Base64 seems to get around this issue.
Is it one particular PNG file, or any file which is 4630 bytes long? Can you post the code you are using to make the query.
I have this same issue, but it is with a has stored in a binary(32) column. My code:
return this._pool.prepare("SELECT * FROM files").then((query) {
return query.execute([]).then((results) {
return results.forEach((row) {
// Stuff done with data
});
});
});
I traced the exception to line 211 of connection.dart, inside the exception catch. The exception that it is trying to report is "Bad UTF-8 encoding 0xee". I presume this is because of the binary column. The catch tries to report the error via completer.completeError, which is fine, but the completer has already been completed elsewhere. I changed catch (e) to catch (e,st) on line 207 and got this stack trace:
This tells us where the original exception is coming from, but I'm still not sure where it's being completed early. There seems to be two issues here: doesn't support retrieving binary (which is fine, but it should be clearly explained), and it is being completed prematurely.
And just for control, this works fine (id is a bigint):
SELECT id FROM files
FYI, my workaround (and I'll probably stick with it, since I need to convert it to a string anyway) is to use:
SELECT id, HEX(hash) hash FROM files
Same problem here. I use a table for storing images as BLOB with variable sizes ranging from 6kb to 16kb. I get the error when executing:
connectionPool.prepareExecute("SELECT * FROM `images` WHERE `id` = ?", [1]).then((Results results) {
...
});
Unhandled exception:
Uncaught Error: Bad state: Future already completed
Stack Trace:
#0 _Completer.completeError (dart:async/future_impl.dart:21)
#1 _handleData (package:sqljocky/src/connection.dart:211:31)
#2 _RootZone.runUnary (dart:async/zone.dart:1155)
#3 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:484)
#4 _Future._propagateToListeners (dart:async/future_impl.dart:567)
#5 _Future._completeWithValue (dart:async/future_impl.dart:358)
#6 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:412)
#7 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#8 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#9 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:886)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
Unfortunately converting my binary data to Base64 is not an option...
mysql --version: mysql Ver 14.14 Distrib 5.5.40, for debian-linux-gnu (x86_64) using readline 6.3
dart --version: Dart VM version: 1.8.0 (Thu Nov 27 06:31:57 2014) on "linux_x64"
Why is this still not fixed? It prevents everybody from using blobs. :(
This is hopefully resolved in the latest commit.
When saving a .PNG file that is 4630 bytes there is no issue. The data is in a LONGBLOB.
mysql --version: _mysql Ver 15.1 Distrib 5.5.37-MariaDB, for Linux (x8664) using readline 5.1
the actual query used is: SELECT * FROM content WHERE pathRaw=?; ["social/logo.png"]
The Stack Trace: Uncaught Error: Bad state: Future already completed Stack Trace:
0 _AsyncCompleter.completeError (dart:async/future_impl.dart:35)
1 _handleData (package:sqljocky/src/connection.dart:211:31)
2 _rootRunUnary (dart:async/zone.dart:730)
3 _RootZone.runUnary (dart:async/zone.dart:864)
4 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
5 _Future._propagateToListeners (dart:async/future_impl.dart:571)
6 _Future._completeWithValue (dart:async/future_impl.dart:331)
7 _Future._asyncComplete. (dart:async/future_impl.dart:393)
8 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
9 _asyncRunCallback (dart:async/schedule_microtask.dart:32)
10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)
in ShutdownIsolate: Unhandled exception: Bad state: Future already completed
0 _rootHandleUncaughtError.. (dart:async/zone.dart:713)
1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
2 _asyncRunCallback (dart:async/schedule_microtask.dart:32)
3 _asyncRunCallback (dart:async/schedule_microtask.dart:36)
4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)