marcucio/Cordova-WP-SqlitePlugin

Possible DROP TABLE solution

Opened this issue · 2 comments

FYI, I've been working on WindowsRT support for WebSQL (using the amalgamated C source rather than CsharpSqlight) and executing multiple DROP TABLE statements within a transaction was failing with SQLITE_ERROR.

It turned out that the issue was cause by my code not initializing the sqlite3_temp_directory. The second DROP TABLE required SQLite to create a temporary file and it couldn't do so since sqlite3_temp_directory was NULL.

It's possible this is the cause of the problem you're facing in your plugin.

http://www.sqlite.org/c3ref/temp_directory.html

great thanks, I will check it out when I get a sec

I was having a bunch of other problems with inserts containing large amounts of data not working (also using the USE_WP8_NATIVE_SQLITE flag) and it turned out setting the SQL temp dir also solved that problem.

Right now I just do this right after the SQLiteConnection is created:

string tempPath = ApplicationData.Current.LocalFolder.Path;
var cmd = this.db.CreateCommand("PRAGMA temp_store_directory = '"+tempPath+"';");
int rowsAffected = cmd.ExecuteNonQuery();