Bug 327 - Mono.Data.Sqlite doesn't work without SQLITE_ENABLE_COLUMN_METADATA
Summary: Mono.Data.Sqlite doesn't work without SQLITE_ENABLE_COLUMN_METADATA
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Data.Sqlite ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: Low normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-08-18 22:14 UTC by mattmc3
Modified: 2013-05-17 17:20 UTC (History)
5 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description mattmc3 2011-08-18 22:14:25 UTC
When browsing a sqlite3 database in the Database Browser, all columns show up as 'smallint' regardless of their actual datatype and when right clicking on a table in the browser and choosing the "select *" or "select x, y..." option, an error is thrown:

System.EntryPointNotFoundException: sqlite3_column_origin_name
  at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods:sqlite3_column_origin_name (intptr,int)
  at Mono.Data.Sqlite.SQLite3.ColumnOriginalName (Mono.Data.Sqlite.SqliteStatement stmt, Int32 index) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:493 
  at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable (Boolean wantUniqueInfo, Boolean wantDefaultValue) [0x0042d] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:619 
  at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:550 
  at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, System.Data.Common.DataTableMappingCollection dtMapping) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:284 
  at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:257 
  at System.Data.Common.DataAdapter.FillTable (System.Data.DataTable dataTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, System.Int32& counter) [0x00011] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:428 
  at System.Data.Common.DataAdapter.FillInternal (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x0009b] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:533 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:589 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) [0x0004e] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:337 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.4/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:265 
  at MonoDevelop.Database.Sql.Sqlite.SqlitePooledDbConnection.ExecuteSet (IDbCommand command) [0x00025] in /sources/monodevelop/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqlitePooledDbConnection.cs:62
Comment 1 Miguel de Icaza [MSFT] 2011-08-23 09:42:36 UTC
Seems like the SQLite shipped with the system is too old and lacks some of the functions Mono's library depend on.

We should still fix the crash, but it wont work properly, unless you install your own up to date SQLite
Comment 2 mattmc3 2011-08-23 20:08:14 UTC
If I go to Terminal and run "sqlite3 --version" I get which appears to be the latest SQLite.  I'm running OS X Lion and "mono --version" gives me 2.10.4.  The error still happens in Mono Develop 2.6 RC2.  So, as far as I can tell, I'm on the latest of everything.
Comment 3 David Hoffmann 2012-06-08 03:58:38 UTC
I have the same problem with Android 1.6 (HTC / Google G1).
Comment 4 Timotheus Pokorra 2013-05-15 10:00:37 UTC
I came across the same problem.
The problem is that by default sqlite is not compiled with the flag SQLITE_ENABLE_COLUMN_METADATA

see also http://www.sqlite.org/compile.html

When I compile sqlite3 from source:
make install

then this error "System.EntryPointNotFoundException: sqlite3_column_origin_name" is gone.
Comment 5 Miguel de Icaza [MSFT] 2013-05-15 10:27:07 UTC
We are unlikely to ship our own version of Sqlite at this point.

This is a shame.
Comment 6 Mikayla Hutchinson [MSFT] 2013-05-15 19:58:25 UTC
The problem is that Mono.Data.Sqlite doesn't work without SQLITE_ENABLE_COLUMN_METADATA, because its implementation of GetSchemaTable uses sqlite3_column_origin_name.

However, sqlite3_column_origin_name doesn't seem to be essential, since that portion of code is conditional disabled in the MONOTOUCH build. Presumably Sqlite on iOS is also built without SQLITE_ENABLE_COLUMN_METADATA.


So this could very easily be robustified by adding this around the region that's currently protected with #if !MONOTOUCH

static bool hasColumnMetadataSupport = true;


if (hasColumnMetadataSupport) {
    try {
        // the code that uses sqlite3_column_origin_name
    } catch (EntryPointNotFoundException) {
        hasColumnMetadataSupport = false;
Comment 7 Mikayla Hutchinson [MSFT] 2013-05-15 20:17:34 UTC
See also bug 2128 - we should fix this to work on Android too.
Comment 8 Mikayla Hutchinson [MSFT] 2013-05-17 17:20:06 UTC
Fixed the exception in Mono.Data.Sqlite by expanding the workaround that Xamarin.iOS uses so that it work everywhere - MacOS, Android, etc.

The table will still be missing metadata, unfortunately. There are some fixes proposed in bug 2128.