Bug 29968 - Mono.Data.SQlite SourceTable is required to be a non-empty string Parameter name: sourceTable
Summary: Mono.Data.SQlite SourceTable is required to be a non-empty string Parameter n...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 8.10
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-05-12 08:14 UTC by matteo
Modified: 2015-11-13 22:41 UTC (History)
7 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test project (376.81 KB, application/zip)
2015-05-12 09:21 UTC, Rolf Bjarne Kvinge [MSFT]
Details

Description matteo 2015-05-12 08:14:49 UTC
After update to Xamarin iOS 8.10.0.267 is impossibile to read SQLite database with Mono.Data.Sqlite

To reproduce the error:

string AppFolder =
Foundation.NSFileManager.DefaultManager.GetUrls(Foundation.NSSearchPathDirectory.LibraryDirectory,
Foundation.NSSearchPathDomain.User)[0].Path;
            string DBName = AppFolder + "/test.db";
            Mono.Data.Sqlite.SqliteConnection Cnn = new
Mono.Data.Sqlite.SqliteConnection("Data source=" + DBName);
            if (System.IO.File.Exists(DBName) == false)
            {
                Mono.Data.Sqlite.SqliteConnection.CreateFile(DBName);
            }

            Cnn.Open();

            Mono.Data.Sqlite.SqliteCommand CreateTableCommand = new
Mono.Data.Sqlite.SqliteCommand("CREATE TABLE IF NOT EXISTS test (field1 int)",
Cnn);
            CreateTableCommand.ExecuteNonQuery();

            Mono.Data.Sqlite.SqliteCommand SelectCommand = new
Mono.Data.Sqlite.SqliteCommand("SELECT * FROM Test", Cnn);
            Mono.Data.Sqlite.SqliteDataAdapter Adapter = new
Mono.Data.Sqlite.SqliteDataAdapter(SelectCommand);

            System.Data.DataTable Data = new System.Data.DataTable();
            Adapter.Fill(Data);
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:21:59 UTC
Created attachment 11163 [details]
Test project
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:22:42 UTC
This looks like a regression in the BCL.

@Marek, can you have a look (or assign more appropriately)?
Comment 3 Marek Safar 2015-05-12 11:45:15 UTC
Could you attach the exception you get
Comment 4 matteo 2015-05-12 11:52:11 UTC
SourceTable is required to be a non-empty string Parameter name: sourceTable
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-05-12 13:22:25 UTC
Full exception details:

> System.ArgumentException: SourceTable is required to be a non-empty string
> Parameter name: sourceTable
>   at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x0002d] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/external/referencesource/System.Data/System/Data/Common/DataTableMappingCollection.cs:383 
>   at System.Data.Common.DataAdapter.SetupSchema (SchemaType schemaType, System.String sourceTableName) [0x00009] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:455 
>   at System.Data.Common.DataAdapter.FillInternal (System.Data.DataTable dataTable, IDataReader dataReader) [0x00015] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:204 
>   at System.Data.Common.DataAdapter.Fill (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:520 
>   at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable, IDbCommand command, CommandBehavior behavior) [0x00022] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:260 
>   at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) [0x00011] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.0.267/src/mono/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:242 
>   at AppDelegate.MiscTapped () [0x00081] in /Users/rolf/Downloads/bug29968/AppDelegate.cs:129 
>   at AppDelegate.<FinishedLaunching>m__1 (MonoTouch.Dialog.GlassButton obj) [0x00003] in /Users/rolf/Downloads/bug29968/AppDelegate.cs:90
Comment 6 matteo 2015-05-13 03:42:47 UTC
The problem appears to be that the new imported Microsoft Reference Source for System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction() enforces an additional requirement that the DataTable passed into Adapter.Fill() must have the DataTable.TableName property set to a non-empty string.
Comment 7 Marek Safar 2015-05-14 11:15:59 UTC
Already fixed in mono master (complete System.Data import)
Comment 8 Shane van Wyk 2015-06-10 18:10:01 UTC
On which version of mono is it fixed? We are sitting on 4.0.1.44 and it is broken. Also when will it go out to the Repos so that it can be updated via Ubuntu package upgrade?
Comment 9 Sylvain 2015-07-03 07:46:50 UTC
Very sadely, 4.0.2.5 does not fix it either. Any ETA for the release of a package that contains the fix mentionned Comment 7?
Comment 10 CoderPersonGuy 2015-07-07 18:19:11 UTC
i'm hitting this also on 4.0.2.5.  any word on when this fix will be released?  is there an easy way to switch to an old version or "beta" that includes it?
Comment 11 CoderPersonGuy 2015-07-07 18:44:07 UTC
I tried to install 3.12.0 to no avail -- apt-get did not like repositories with / in the name.  Seems to be a known issue.

So I install the nightly.  I now get a different crash:

Exception: NullReferenceException: Object reference not set to an instance of an object
  at System.Data.SqlClient.SqlDataReader.GetValues (System.Object[] values) <0x40984000 + 0x0006d> in <filename unknown>:0 
  at System.Data.ProviderBase.DataReaderContainer+CommonLanguageSubsetDataReader.GetValues (System.Object[] values) <0x40983f90 + 0x00029> in <filename unknown>:0 
  at System.Data.ProviderBase.SchemaMapping.LoadDataRow () <0x40983d90 + 0x00030> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillLoadDataRow (System.Data.ProviderBase.SchemaMapping mapping) <0x40983910 + 0x00137> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillFromReader (System.Data.DataSet dataset, System.Data.DataTable datatable, System.String srcTable, System.Data.ProviderBase.DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, System.Data.DataColumn parentChapterColumn, System.Object parentChapterValue) <0x4097d300 + 0x0011b> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) <0x4097c920 + 0x00287> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.FillInternal (System.Data.DataSet dataset, System.Data.DataTable[] datatables, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) <0x4097bcb0 + 0x0011c> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) <0x4097b9f0 + 0x00173> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) <0x4097b740 + 0x000c2> in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
Comment 12 Brendan Zagaeski (Xamarin Support) 2015-11-13 22:41:34 UTC
The problem from the nightly in Comment 11 seems to require different conditions to reproduce. I was able to reproduce it with a different test case, and I have accordingly filed a bug for it here:

Bug 35857

(Side note: to a first approximation, a new bug report will be needed any time the unhandled exception that's causing a crash changes.)


Best,
Brendan
Xamarin Customer Support

Note You need to log in before you can comment on or make changes to this bug.