diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index a032670588..636bf8645b 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -30,7 +30,7 @@ using System.Data; using System.Reflection; using System.Collections.Generic; using log4net; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using OpenMetaverse; using OpenSim.Framework; @@ -137,7 +137,7 @@ namespace OpenSim.Data.SQLite cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); - + cmd.ExecuteNonQuery(); } } @@ -340,4 +340,4 @@ namespace OpenSim.Data.SQLite #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs index aa10734d50..086ac0a972 100644 --- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { @@ -56,13 +56,8 @@ namespace OpenSim.Data.SQLite m_Connection = new SqliteConnection(connectionString); m_Connection.Open(); - using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone()) - { - dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); - m.Update(); - dbcon.Close(); - } + Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); + m.Update(); m_initialized = true; } @@ -113,7 +108,7 @@ namespace OpenSim.Data.SQLite } finally { - CloseCommand(cmd); + //CloseCommand(cmd); } return null; @@ -156,14 +151,14 @@ namespace OpenSim.Data.SQLite { if (ExecuteNonQuery(cmd, m_Connection) < 1) { - CloseCommand(cmd); + //CloseCommand(cmd); return false; } } catch (Exception e) { Console.WriteLine(e.ToString()); - CloseCommand(cmd); + //CloseCommand(cmd); return false; } } @@ -184,19 +179,19 @@ namespace OpenSim.Data.SQLite { if (ExecuteNonQuery(cmd, m_Connection) < 1) { - CloseCommand(cmd); + //CloseCommand(cmd); return false; } } catch (Exception e) { Console.WriteLine(e.ToString()); - CloseCommand(cmd); + //CloseCommand(cmd); return false; } } - CloseCommand(cmd); + //CloseCommand(cmd); return true; } diff --git a/OpenSim/Data/SQLite/SQLiteAvatarData.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs index b3f4a4c077..c093884db4 100644 --- a/OpenSim/Data/SQLite/SQLiteAvatarData.cs +++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs @@ -33,7 +33,7 @@ using System.Threading; using log4net; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { @@ -55,8 +55,8 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); - cmd.Parameters.Add(":PrincipalID", principalID.ToString()); - cmd.Parameters.Add(":Name", name); + cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue(":Name", name); try { @@ -67,7 +67,7 @@ namespace OpenSim.Data.SQLite } finally { - CloseCommand(cmd); + //CloseCommand(cmd); } } } diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index bd6b776f80..9dd4a2e69b 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -62,8 +62,8 @@ namespace OpenSim.Data.SQLite Migration m = new Migration(m_connection, assem, "EstateStore"); m.Update(); - m_connection.Close(); - m_connection.Open(); + //m_connection.Close(); + // m_connection.Open(); Type t = typeof(EstateSettings); m_Fields = t.GetFields(BindingFlags.NonPublic | @@ -87,7 +87,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.Add(":RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); return DoLoad(cmd, regionID, create); } @@ -143,13 +143,13 @@ namespace OpenSim.Data.SQLite if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add(":"+name, "1"); + cmd.Parameters.AddWithValue(":"+name, "1"); else - cmd.Parameters.Add(":"+name, "0"); + cmd.Parameters.AddWithValue(":"+name, "0"); } else { - cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -167,8 +167,8 @@ namespace OpenSim.Data.SQLite r.Close(); cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.Add(":RegionID", regionID.ToString()); - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); // This will throw on dupe key try @@ -211,13 +211,13 @@ namespace OpenSim.Data.SQLite if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add(":"+name, "1"); + cmd.Parameters.AddWithValue(":"+name, "1"); else - cmd.Parameters.Add(":"+name, "0"); + cmd.Parameters.AddWithValue(":"+name, "0"); } else { - cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -236,7 +236,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", es.EstateID); + cmd.Parameters.AddWithValue(":EstateID", es.EstateID); IDataReader r = cmd.ExecuteReader(); @@ -260,7 +260,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "delete from estateban where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -270,8 +270,8 @@ namespace OpenSim.Data.SQLite foreach (EstateBan b in es.EstateBans) { - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); - cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -283,7 +283,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -293,8 +293,8 @@ namespace OpenSim.Data.SQLite foreach (UUID uuid in data) { - cmd.Parameters.Add(":EstateID", EstateID.ToString()); - cmd.Parameters.Add(":uuid", uuid.ToString()); + cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -308,7 +308,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", EstateID); + cmd.Parameters.AddWithValue(":EstateID", EstateID); IDataReader r = cmd.ExecuteReader(); @@ -333,7 +333,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.Add(":EstateID", estateID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); return DoLoad(cmd, UUID.Zero, false); } @@ -347,7 +347,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.Add(":EstateName", search); + cmd.Parameters.AddWithValue(":EstateName", search); IDataReader r = cmd.ExecuteReader(); @@ -365,8 +365,8 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.Add(":RegionID", regionID.ToString()); - cmd.Parameters.Add(":EstateID", estateID.ToString()); + cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); if (cmd.ExecuteNonQuery() == 0) return false; diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 20b508515a..cf114d1a07 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { @@ -55,11 +55,14 @@ namespace OpenSim.Data.SQLite { lock (connection) { +/* SqliteConnection newConnection = (SqliteConnection)((ICloneable)connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; +*/ + cmd.Connection = connection; //Console.WriteLine("XXX " + cmd.CommandText); return cmd.ExecuteNonQuery(); @@ -70,11 +73,12 @@ namespace OpenSim.Data.SQLite { lock (connection) { - SqliteConnection newConnection = - (SqliteConnection)((ICloneable)connection).Clone(); - newConnection.Open(); + //SqliteConnection newConnection = + // (SqliteConnection)((ICloneable)connection).Clone(); + //newConnection.Open(); - cmd.Connection = newConnection; + //cmd.Connection = newConnection; + cmd.Connection = connection; //Console.WriteLine("XXX " + cmd.CommandText); return cmd.ExecuteReader(); diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index 0b121826d6..b06853ce68 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { @@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); - cmd.Parameters.Add(":PrincipalID", userID.ToString()); + cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); return DoQuery(cmd); @@ -58,8 +58,8 @@ namespace OpenSim.Data.SQLite SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); - cmd.Parameters.Add(":PrincipalID", principalID.ToString()); - cmd.Parameters.Add(":Friend", friend); + cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue(":Friend", friend); ExecuteNonQuery(cmd, cmd.Connection); diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index b39bb19fb7..3c70aeffc4 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -59,19 +59,21 @@ namespace OpenSim.Data.SQLite if (!m_initialized) { m_Connection = new SqliteConnection(connectionString); + Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString)); m_Connection.Open(); if (storeName != String.Empty) { Assembly assem = GetType().Assembly; - SqliteConnection newConnection = - (SqliteConnection)((ICloneable)m_Connection).Clone(); - newConnection.Open(); + //SqliteConnection newConnection = + // (SqliteConnection)((ICloneable)m_Connection).Clone(); + //newConnection.Open(); - Migration m = new Migration(newConnection, assem, storeName); + //Migration m = new Migration(newConnection, assem, storeName); + Migration m = new Migration(m_Connection, assem, storeName); m.Update(); - newConnection.Close(); - newConnection.Dispose(); + //newConnection.Close(); + //newConnection.Dispose(); } m_initialized = true; @@ -197,7 +199,7 @@ namespace OpenSim.Data.SQLite result.Add(row); } - CloseCommand(cmd); + //CloseCommand(cmd); return result.ToArray(); } diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index a5e051726e..ece2495c2b 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using OpenMetaverse; using OpenSim.Framework; @@ -98,11 +98,13 @@ namespace OpenSim.Data.SQLite ds.Tables.Add(createInventoryFoldersTable()); invFoldersDa.Fill(ds.Tables["inventoryfolders"]); setupFoldersCommands(invFoldersDa, conn); + CreateDataSetMapping(invFoldersDa, "inventoryfolders"); m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); ds.Tables.Add(createInventoryItemsTable()); invItemsDa.Fill(ds.Tables["inventoryitems"]); setupItemsCommands(invItemsDa, conn); + CreateDataSetMapping(invItemsDa, "inventoryitems"); m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); ds.AcceptChanges(); @@ -728,6 +730,15 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + protected void CreateDataSetMapping(IDataAdapter da, string tableName) + { + ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); + foreach (DataColumn col in ds.Tables[tableName].Columns) + { + dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); + } + } + /// /// Create the "inventoryitems" table /// diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index d2ba9ae298..0217748b93 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -32,7 +32,7 @@ using System.Drawing; using System.IO; using System.Reflection; using log4net; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -87,119 +87,142 @@ namespace OpenSim.Data.SQLite /// the connection string public void Initialise(string connectionString) { - m_connectionString = connectionString; - - ds = new DataSet(); - - m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); - m_conn = new SqliteConnection(m_connectionString); - m_conn.Open(); - - - - SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); - primDa = new SqliteDataAdapter(primSelectCmd); - // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); - - SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); - shapeDa = new SqliteDataAdapter(shapeSelectCmd); - // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); - - SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); - itemsDa = new SqliteDataAdapter(itemsSelectCmd); - - SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); - terrainDa = new SqliteDataAdapter(terrainSelectCmd); - - SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); - landDa = new SqliteDataAdapter(landSelectCmd); - - SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); - landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); - - SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); - regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_conn, assem, "RegionStore"); - m.Update(); - - lock (ds) + try { - ds.Tables.Add(createPrimTable()); - setupPrimCommands(primDa, m_conn); - primDa.Fill(ds.Tables["prims"]); + m_connectionString = connectionString; - ds.Tables.Add(createShapeTable()); - setupShapeCommands(shapeDa, m_conn); + ds = new DataSet("Region"); - ds.Tables.Add(createItemsTable()); - setupItemsCommands(itemsDa, m_conn); - itemsDa.Fill(ds.Tables["primitems"]); + m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); + m_conn = new SqliteConnection(m_connectionString); + m_conn.Open(); - ds.Tables.Add(createTerrainTable()); - setupTerrainCommands(terrainDa, m_conn); + SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); + primDa = new SqliteDataAdapter(primSelectCmd); - ds.Tables.Add(createLandTable()); - setupLandCommands(landDa, m_conn); + SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); + shapeDa = new SqliteDataAdapter(shapeSelectCmd); + // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); - ds.Tables.Add(createLandAccessListTable()); - setupLandAccessCommands(landAccessListDa, m_conn); + SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); + itemsDa = new SqliteDataAdapter(itemsSelectCmd); - ds.Tables.Add(createRegionSettingsTable()); - - setupRegionSettingsCommands(regionSettingsDa, m_conn); + SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); + terrainDa = new SqliteDataAdapter(terrainSelectCmd); - // WORKAROUND: This is a work around for sqlite on - // windows, which gets really unhappy with blob columns - // that have no sample data in them. At some point we - // need to actually find a proper way to handle this. - try + SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); + landDa = new SqliteDataAdapter(landSelectCmd); + + SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); + landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); + + SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); + regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_conn, assem, "RegionStore"); + m.Update(); + + lock (ds) { - shapeDa.Fill(ds.Tables["primshapes"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on primshapes table"); - } + ds.Tables.Add(createPrimTable()); + setupPrimCommands(primDa, m_conn); - try - { - terrainDa.Fill(ds.Tables["terrain"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on terrain table"); - } + ds.Tables.Add(createShapeTable()); + setupShapeCommands(shapeDa, m_conn); - try - { - landDa.Fill(ds.Tables["land"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on land table"); - } + ds.Tables.Add(createItemsTable()); + setupItemsCommands(itemsDa, m_conn); - try - { - landAccessListDa.Fill(ds.Tables["landaccesslist"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); - } + ds.Tables.Add(createTerrainTable()); + setupTerrainCommands(terrainDa, m_conn); - try - { - regionSettingsDa.Fill(ds.Tables["regionsettings"]); + ds.Tables.Add(createLandTable()); + setupLandCommands(landDa, m_conn); + + ds.Tables.Add(createLandAccessListTable()); + setupLandAccessCommands(landAccessListDa, m_conn); + + ds.Tables.Add(createRegionSettingsTable()); + setupRegionSettingsCommands(regionSettingsDa, m_conn); + + // WORKAROUND: This is a work around for sqlite on + // windows, which gets really unhappy with blob columns + // that have no sample data in them. At some point we + // need to actually find a proper way to handle this. + try + { + primDa.Fill(ds.Tables["prims"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on prims table"); + } + + try + { + shapeDa.Fill(ds.Tables["primshapes"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on primshapes table"); + } + + try + { + terrainDa.Fill(ds.Tables["terrain"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on terrain table"); + } + + try + { + landDa.Fill(ds.Tables["land"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on land table"); + } + + try + { + landAccessListDa.Fill(ds.Tables["landaccesslist"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); + } + + try + { + regionSettingsDa.Fill(ds.Tables["regionsettings"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); + } + + // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values! + // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409 + // Possibly because we manually set up our own DataTables before connecting to the database + CreateDataSetMapping(primDa, "prims"); + CreateDataSetMapping(shapeDa, "primshapes"); + CreateDataSetMapping(itemsDa, "primitems"); + CreateDataSetMapping(terrainDa, "terrain"); + CreateDataSetMapping(landDa, "land"); + CreateDataSetMapping(landAccessListDa, "landaccesslist"); + CreateDataSetMapping(regionSettingsDa, "regionsettings"); } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); - } - return; } + catch (Exception e) + { + m_log.Error(e); + Environment.Exit(23); + } + + return; } public void Dispose() @@ -603,7 +626,7 @@ namespace OpenSim.Data.SQLite } } } - rev = (int) row["Revision"]; + rev = Convert.ToInt32(row["Revision"]); } else { @@ -755,6 +778,7 @@ namespace OpenSim.Data.SQLite /// public void Commit() { + m_log.Debug("[SQLITE]: Starting commit"); lock (ds) { primDa.Update(ds, "prims"); @@ -769,18 +793,11 @@ namespace OpenSim.Data.SQLite { regionSettingsDa.Update(ds, "regionsettings"); } - catch (SqliteExecutionException SqlEx) + catch (SqliteException SqlEx) { - if (SqlEx.Message.Contains("logic error")) - { - throw new Exception( - "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", - SqlEx); - } - else - { - throw SqlEx; - } + throw new Exception( + "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", + SqlEx); } ds.AcceptChanges(); } @@ -802,6 +819,15 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + protected void CreateDataSetMapping(IDataAdapter da, string tableName) + { + ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); + foreach (DataColumn col in ds.Tables[tableName].Columns) + { + dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); + } + } + /// /// /// @@ -1964,6 +1990,7 @@ namespace OpenSim.Data.SQLite sql += ") values (:"; sql += String.Join(", :", cols); sql += ")"; + m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql); SqliteCommand cmd = new SqliteCommand(sql); // this provides the binding for all our parameters, so @@ -2259,6 +2286,36 @@ namespace OpenSim.Data.SQLite return DbType.String; } } + + static void PrintDataSet(DataSet ds) + { + // Print out any name and extended properties. + Console.WriteLine("DataSet is named: {0}", ds.DataSetName); + foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties) + { + Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); + } + Console.WriteLine(); + foreach (DataTable dt in ds.Tables) + { + Console.WriteLine("=> {0} Table:", dt.TableName); + // Print out the column names. + for (int curCol = 0; curCol < dt.Columns.Count; curCol++) + { + Console.Write(dt.Columns[curCol].ColumnName + "\t"); + } + Console.WriteLine("\n----------------------------------"); + // Print the DataTable. + for (int curRow = 0; curRow < dt.Rows.Count; curRow++) + { + for (int curCol = 0; curCol < dt.Columns.Count; curCol++) + { + Console.Write(dt.Rows[curRow][curCol].ToString() + "\t"); + } + Console.WriteLine(); + } + } + } } } diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index 67cf7165b1..893f105604 100644 --- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { @@ -66,7 +66,7 @@ namespace OpenSim.Data.SQLite if (words.Length == 1) { - cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", + cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", m_Realm, scopeID.ToString(), words[0]); } else diff --git a/OpenSim/Data/SQLite/SQLiteUtils.cs b/OpenSim/Data/SQLite/SQLiteUtils.cs index 4a835ce52f..07c6b69a3b 100644 --- a/OpenSim/Data/SQLite/SQLiteUtils.cs +++ b/OpenSim/Data/SQLite/SQLiteUtils.cs @@ -27,7 +27,7 @@ using System; using System.Data; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; namespace OpenSim.Data.SQLite { diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index a66e0c6fe0..be1d0412fd 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs @@ -29,7 +29,7 @@ using System; using System.Data; using System.Reflection; using System.Collections.Generic; -using Mono.Data.SqliteClient; +using Mono.Data.Sqlite; using log4net; using OpenMetaverse; using OpenSim.Framework; @@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLite } reader.Close(); - CloseCommand(cmd); + //CloseCommand(cmd); return perms; } diff --git a/OpenSim/Data/SQLiteNG/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs similarity index 96% rename from OpenSim/Data/SQLiteNG/Properties/AssemblyInfo.cs rename to OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs index 4aeb67b375..609a024b73 100644 --- a/OpenSim/Data/SQLiteNG/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs @@ -32,11 +32,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly : AssemblyTitle("OpenSim.Data.SQLiteNG")] +[assembly : AssemblyTitle("OpenSim.Data.SQLiteLegacy")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("http://opensimulator.org")] -[assembly : AssemblyProduct("OpenSim.Data.SQLiteNG")] +[assembly : AssemblyProduct("OpenSim.Data.SQLiteLegacy")] [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] diff --git a/OpenSim/Data/SQLiteNG/Resources/001_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_AssetStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_AuthStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_Avatar.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_Avatar.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_FriendsStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_InventoryStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_UserAccount.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/001_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/001_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_AssetStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_AuthStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_FriendsStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_InventoryStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_UserAccount.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/002_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/002_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/003_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/003_AssetStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/003_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/003_InventoryStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/003_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/003_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/003_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/003_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/004_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/004_AssetStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/004_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/004_InventoryStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/004_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/004_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/004_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/004_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/005_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/005_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/005_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/005_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/006_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/006_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/006_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/006_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/007_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/007_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/007_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/007_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/008_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/008_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/008_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/008_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/009_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/009_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/009_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/009_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/010_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/010_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/010_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/010_UserStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/011_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/011_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/012_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/012_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/013_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/013_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/014_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/014_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/015_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/015_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/016_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/016_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/017_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/017_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/018_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/018_RegionStore.sql rename to OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql diff --git a/OpenSim/Data/SQLiteNG/Resources/OpenSim.Data.SQLite.addin.xml b/OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml similarity index 100% rename from OpenSim/Data/SQLiteNG/Resources/OpenSim.Data.SQLite.addin.xml rename to OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml diff --git a/OpenSim/Data/SQLiteNG/SQLiteAssetData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs similarity index 99% rename from OpenSim/Data/SQLiteNG/SQLiteAssetData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs index 9b34a21592..0d63deacd8 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs @@ -30,11 +30,11 @@ using System.Data; using System.Reflection; using System.Collections.Generic; using log4net; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using OpenMetaverse; using OpenSim.Framework; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// An asset storage interface for the SQLite database system @@ -137,7 +137,7 @@ namespace OpenSim.Data.SQLiteNG cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); - + cmd.ExecuteNonQuery(); } } @@ -340,4 +340,4 @@ namespace OpenSim.Data.SQLiteNG #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Data/SQLiteNG/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs similarity index 93% rename from OpenSim/Data/SQLiteNG/SQLiteAuthenticationData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs index 4a5dc2eeba..c64830a455 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData { @@ -56,8 +56,13 @@ namespace OpenSim.Data.SQLiteNG m_Connection = new SqliteConnection(connectionString); m_Connection.Open(); - Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); - m.Update(); + using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone()) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); + m.Update(); + dbcon.Close(); + } m_initialized = true; } @@ -108,7 +113,7 @@ namespace OpenSim.Data.SQLiteNG } finally { - //CloseCommand(cmd); + CloseCommand(cmd); } return null; @@ -151,14 +156,14 @@ namespace OpenSim.Data.SQLiteNG { if (ExecuteNonQuery(cmd, m_Connection) < 1) { - //CloseCommand(cmd); + CloseCommand(cmd); return false; } } catch (Exception e) { Console.WriteLine(e.ToString()); - //CloseCommand(cmd); + CloseCommand(cmd); return false; } } @@ -179,19 +184,19 @@ namespace OpenSim.Data.SQLiteNG { if (ExecuteNonQuery(cmd, m_Connection) < 1) { - //CloseCommand(cmd); + CloseCommand(cmd); return false; } } catch (Exception e) { Console.WriteLine(e.ToString()); - //CloseCommand(cmd); + CloseCommand(cmd); return false; } } - //CloseCommand(cmd); + CloseCommand(cmd); return true; } diff --git a/OpenSim/Data/SQLiteNG/SQLiteAvatarData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs similarity index 92% rename from OpenSim/Data/SQLiteNG/SQLiteAvatarData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs index d0fd49c5ae..660632ca07 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteAvatarData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs @@ -33,9 +33,9 @@ using System.Threading; using log4net; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// A SQLite Interface for Avatar Data @@ -55,8 +55,8 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue(":Name", name); + cmd.Parameters.Add(":PrincipalID", principalID.ToString()); + cmd.Parameters.Add(":Name", name); try { @@ -67,7 +67,7 @@ namespace OpenSim.Data.SQLiteNG } finally { - //CloseCommand(cmd); + CloseCommand(cmd); } } } diff --git a/OpenSim/Data/SQLiteNG/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs similarity index 87% rename from OpenSim/Data/SQLiteNG/SQLiteEstateData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs index 2e2d717cc9..e135eaa524 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs @@ -30,12 +30,12 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { public class SQLiteEstateStore : IEstateDataStore { @@ -62,8 +62,8 @@ namespace OpenSim.Data.SQLiteNG Migration m = new Migration(m_connection, assem, "EstateStore"); m.Update(); - //m_connection.Close(); - // m_connection.Open(); + m_connection.Close(); + m_connection.Open(); Type t = typeof(EstateSettings); m_Fields = t.GetFields(BindingFlags.NonPublic | @@ -87,7 +87,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); + cmd.Parameters.Add(":RegionID", regionID.ToString()); return DoLoad(cmd, regionID, create); } @@ -143,13 +143,13 @@ namespace OpenSim.Data.SQLiteNG if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue(":"+name, "1"); + cmd.Parameters.Add(":"+name, "1"); else - cmd.Parameters.AddWithValue(":"+name, "0"); + cmd.Parameters.Add(":"+name, "0"); } else { - cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -167,8 +167,8 @@ namespace OpenSim.Data.SQLiteNG r.Close(); cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); + cmd.Parameters.Add(":RegionID", regionID.ToString()); + cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); // This will throw on dupe key try @@ -211,13 +211,13 @@ namespace OpenSim.Data.SQLiteNG if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue(":"+name, "1"); + cmd.Parameters.Add(":"+name, "1"); else - cmd.Parameters.AddWithValue(":"+name, "0"); + cmd.Parameters.Add(":"+name, "0"); } else { - cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -236,7 +236,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", es.EstateID); + cmd.Parameters.Add(":EstateID", es.EstateID); IDataReader r = cmd.ExecuteReader(); @@ -260,7 +260,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "delete from estateban where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); + cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -270,8 +270,8 @@ namespace OpenSim.Data.SQLiteNG foreach (EstateBan b in es.EstateBans) { - cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); + cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); + cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -283,7 +283,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); + cmd.Parameters.Add(":EstateID", EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -293,8 +293,8 @@ namespace OpenSim.Data.SQLiteNG foreach (UUID uuid in data) { - cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); + cmd.Parameters.Add(":EstateID", EstateID.ToString()); + cmd.Parameters.Add(":uuid", uuid.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -308,7 +308,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", EstateID); + cmd.Parameters.Add(":EstateID", EstateID); IDataReader r = cmd.ExecuteReader(); @@ -333,7 +333,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); + cmd.Parameters.Add(":EstateID", estateID.ToString()); return DoLoad(cmd, UUID.Zero, false); } @@ -347,7 +347,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":EstateName", search); + cmd.Parameters.Add(":EstateName", search); IDataReader r = cmd.ExecuteReader(); @@ -365,8 +365,8 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); + cmd.Parameters.Add(":RegionID", regionID.ToString()); + cmd.Parameters.Add(":EstateID", estateID.ToString()); if (cmd.ExecuteNonQuery() == 0) return false; diff --git a/OpenSim/Data/SQLiteNG/SQLiteFramework.cs b/OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs similarity index 89% rename from OpenSim/Data/SQLiteNG/SQLiteFramework.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs index f0ddc597bd..606478ea7e 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteFramework.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// A database interface class to a user profile storage system @@ -55,14 +55,11 @@ namespace OpenSim.Data.SQLiteNG { lock (connection) { -/* SqliteConnection newConnection = (SqliteConnection)((ICloneable)connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; -*/ - cmd.Connection = connection; //Console.WriteLine("XXX " + cmd.CommandText); return cmd.ExecuteNonQuery(); @@ -73,12 +70,11 @@ namespace OpenSim.Data.SQLiteNG { lock (connection) { - //SqliteConnection newConnection = - // (SqliteConnection)((ICloneable)connection).Clone(); - //newConnection.Open(); + SqliteConnection newConnection = + (SqliteConnection)((ICloneable)connection).Clone(); + newConnection.Open(); - //cmd.Connection = newConnection; - cmd.Connection = connection; + cmd.Connection = newConnection; //Console.WriteLine("XXX " + cmd.CommandText); return cmd.ExecuteReader(); diff --git a/OpenSim/Data/SQLiteNG/SQLiteFriendsData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs similarity index 91% rename from OpenSim/Data/SQLiteNG/SQLiteFriendsData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs index 702a1d8643..d529d4d8ab 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { public class SQLiteFriendsData : SQLiteGenericTableHandler, IFriendsData { @@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); + cmd.Parameters.Add(":PrincipalID", userID.ToString()); return DoQuery(cmd); @@ -58,8 +58,8 @@ namespace OpenSim.Data.SQLiteNG SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue(":Friend", friend); + cmd.Parameters.Add(":PrincipalID", principalID.ToString()); + cmd.Parameters.Add(":Friend", friend); ExecuteNonQuery(cmd, cmd.Connection); diff --git a/OpenSim/Data/SQLiteNG/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs similarity index 93% rename from OpenSim/Data/SQLiteNG/SQLiteGenericTableHandler.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs index 632c5bf8c9..1c1fe8cc0f 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs @@ -30,12 +30,12 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { public class SQLiteGenericTableHandler : SQLiteFramework where T: class, new() { @@ -59,21 +59,19 @@ namespace OpenSim.Data.SQLiteNG if (!m_initialized) { m_Connection = new SqliteConnection(connectionString); - Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString)); m_Connection.Open(); if (storeName != String.Empty) { Assembly assem = GetType().Assembly; - //SqliteConnection newConnection = - // (SqliteConnection)((ICloneable)m_Connection).Clone(); - //newConnection.Open(); + SqliteConnection newConnection = + (SqliteConnection)((ICloneable)m_Connection).Clone(); + newConnection.Open(); - //Migration m = new Migration(newConnection, assem, storeName); - Migration m = new Migration(m_Connection, assem, storeName); + Migration m = new Migration(newConnection, assem, storeName); m.Update(); - //newConnection.Close(); - //newConnection.Dispose(); + newConnection.Close(); + newConnection.Dispose(); } m_initialized = true; @@ -199,7 +197,7 @@ namespace OpenSim.Data.SQLiteNG result.Add(row); } - //CloseCommand(cmd); + CloseCommand(cmd); return result.ToArray(); } diff --git a/OpenSim/Data/SQLiteNG/SQLiteInventoryStore.cs b/OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs similarity index 98% rename from OpenSim/Data/SQLiteNG/SQLiteInventoryStore.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs index 9207ca3cc4..726703b79d 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs @@ -30,11 +30,11 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using log4net; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using OpenMetaverse; using OpenSim.Framework; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// An Inventory Interface to the SQLite database @@ -98,13 +98,11 @@ namespace OpenSim.Data.SQLiteNG ds.Tables.Add(createInventoryFoldersTable()); invFoldersDa.Fill(ds.Tables["inventoryfolders"]); setupFoldersCommands(invFoldersDa, conn); - CreateDataSetMapping(invFoldersDa, "inventoryfolders"); m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); ds.Tables.Add(createInventoryItemsTable()); invItemsDa.Fill(ds.Tables["inventoryitems"]); setupItemsCommands(invItemsDa, conn); - CreateDataSetMapping(invItemsDa, "inventoryitems"); m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); ds.AcceptChanges(); @@ -730,15 +728,6 @@ namespace OpenSim.Data.SQLiteNG * **********************************************************************/ - protected void CreateDataSetMapping(IDataAdapter da, string tableName) - { - ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); - foreach (DataColumn col in ds.Tables[tableName].Columns) - { - dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); - } - } - /// /// Create the "inventoryitems" table /// diff --git a/OpenSim/Data/SQLiteNG/SQLiteRegionData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs similarity index 91% rename from OpenSim/Data/SQLiteNG/SQLiteRegionData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs index 289d626543..eb78037bb1 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs @@ -32,13 +32,13 @@ using System.Drawing; using System.IO; using System.Reflection; using log4net; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// A RegionData Interface to the SQLite database @@ -87,142 +87,119 @@ namespace OpenSim.Data.SQLiteNG /// the connection string public void Initialise(string connectionString) { - try + m_connectionString = connectionString; + + ds = new DataSet(); + + m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); + m_conn = new SqliteConnection(m_connectionString); + m_conn.Open(); + + + + SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); + primDa = new SqliteDataAdapter(primSelectCmd); + // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); + + SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); + shapeDa = new SqliteDataAdapter(shapeSelectCmd); + // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); + + SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); + itemsDa = new SqliteDataAdapter(itemsSelectCmd); + + SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); + terrainDa = new SqliteDataAdapter(terrainSelectCmd); + + SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); + landDa = new SqliteDataAdapter(landSelectCmd); + + SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); + landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); + + SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); + regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_conn, assem, "RegionStore"); + m.Update(); + + lock (ds) { - m_connectionString = connectionString; + ds.Tables.Add(createPrimTable()); + setupPrimCommands(primDa, m_conn); + primDa.Fill(ds.Tables["prims"]); - ds = new DataSet("Region"); + ds.Tables.Add(createShapeTable()); + setupShapeCommands(shapeDa, m_conn); - m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); - m_conn = new SqliteConnection(m_connectionString); - m_conn.Open(); + ds.Tables.Add(createItemsTable()); + setupItemsCommands(itemsDa, m_conn); + itemsDa.Fill(ds.Tables["primitems"]); - SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); - primDa = new SqliteDataAdapter(primSelectCmd); + ds.Tables.Add(createTerrainTable()); + setupTerrainCommands(terrainDa, m_conn); - SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); - shapeDa = new SqliteDataAdapter(shapeSelectCmd); - // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); + ds.Tables.Add(createLandTable()); + setupLandCommands(landDa, m_conn); - SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); - itemsDa = new SqliteDataAdapter(itemsSelectCmd); + ds.Tables.Add(createLandAccessListTable()); + setupLandAccessCommands(landAccessListDa, m_conn); - SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); - terrainDa = new SqliteDataAdapter(terrainSelectCmd); + ds.Tables.Add(createRegionSettingsTable()); + + setupRegionSettingsCommands(regionSettingsDa, m_conn); - SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); - landDa = new SqliteDataAdapter(landSelectCmd); - - SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); - landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); - - SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); - regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_conn, assem, "RegionStore"); - m.Update(); - - lock (ds) + // WORKAROUND: This is a work around for sqlite on + // windows, which gets really unhappy with blob columns + // that have no sample data in them. At some point we + // need to actually find a proper way to handle this. + try { - ds.Tables.Add(createPrimTable()); - setupPrimCommands(primDa, m_conn); - - ds.Tables.Add(createShapeTable()); - setupShapeCommands(shapeDa, m_conn); - - ds.Tables.Add(createItemsTable()); - setupItemsCommands(itemsDa, m_conn); - - ds.Tables.Add(createTerrainTable()); - setupTerrainCommands(terrainDa, m_conn); - - ds.Tables.Add(createLandTable()); - setupLandCommands(landDa, m_conn); - - ds.Tables.Add(createLandAccessListTable()); - setupLandAccessCommands(landAccessListDa, m_conn); - - ds.Tables.Add(createRegionSettingsTable()); - setupRegionSettingsCommands(regionSettingsDa, m_conn); - - // WORKAROUND: This is a work around for sqlite on - // windows, which gets really unhappy with blob columns - // that have no sample data in them. At some point we - // need to actually find a proper way to handle this. - try - { - primDa.Fill(ds.Tables["prims"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on prims table"); - } - - try - { - shapeDa.Fill(ds.Tables["primshapes"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on primshapes table"); - } - - try - { - terrainDa.Fill(ds.Tables["terrain"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on terrain table"); - } - - try - { - landDa.Fill(ds.Tables["land"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on land table"); - } - - try - { - landAccessListDa.Fill(ds.Tables["landaccesslist"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); - } - - try - { - regionSettingsDa.Fill(ds.Tables["regionsettings"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); - } - - // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values! - // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409 - // Possibly because we manually set up our own DataTables before connecting to the database - CreateDataSetMapping(primDa, "prims"); - CreateDataSetMapping(shapeDa, "primshapes"); - CreateDataSetMapping(itemsDa, "primitems"); - CreateDataSetMapping(terrainDa, "terrain"); - CreateDataSetMapping(landDa, "land"); - CreateDataSetMapping(landAccessListDa, "landaccesslist"); - CreateDataSetMapping(regionSettingsDa, "regionsettings"); + shapeDa.Fill(ds.Tables["primshapes"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on primshapes table"); } - } - catch (Exception e) - { - m_log.Error(e); - Environment.Exit(23); - } - return; + try + { + terrainDa.Fill(ds.Tables["terrain"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on terrain table"); + } + + try + { + landDa.Fill(ds.Tables["land"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on land table"); + } + + try + { + landAccessListDa.Fill(ds.Tables["landaccesslist"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); + } + + try + { + regionSettingsDa.Fill(ds.Tables["regionsettings"]); + } + catch (Exception) + { + m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); + } + return; + } } public void Dispose() @@ -626,7 +603,7 @@ namespace OpenSim.Data.SQLiteNG } } } - rev = Convert.ToInt32(row["Revision"]); + rev = (int) row["Revision"]; } else { @@ -778,7 +755,6 @@ namespace OpenSim.Data.SQLiteNG /// public void Commit() { - m_log.Debug("[SQLITE]: Starting commit"); lock (ds) { primDa.Update(ds, "prims"); @@ -793,11 +769,18 @@ namespace OpenSim.Data.SQLiteNG { regionSettingsDa.Update(ds, "regionsettings"); } - catch (SqliteException SqlEx) + catch (SqliteExecutionException SqlEx) { - throw new Exception( - "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", - SqlEx); + if (SqlEx.Message.Contains("logic error")) + { + throw new Exception( + "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", + SqlEx); + } + else + { + throw SqlEx; + } } ds.AcceptChanges(); } @@ -819,15 +802,6 @@ namespace OpenSim.Data.SQLiteNG * **********************************************************************/ - protected void CreateDataSetMapping(IDataAdapter da, string tableName) - { - ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); - foreach (DataColumn col in ds.Tables[tableName].Columns) - { - dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); - } - } - /// /// /// @@ -1990,7 +1964,6 @@ namespace OpenSim.Data.SQLiteNG sql += ") values (:"; sql += String.Join(", :", cols); sql += ")"; - m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql); SqliteCommand cmd = new SqliteCommand(sql); // this provides the binding for all our parameters, so @@ -2286,36 +2259,6 @@ namespace OpenSim.Data.SQLiteNG return DbType.String; } } - - static void PrintDataSet(DataSet ds) - { - // Print out any name and extended properties. - Console.WriteLine("DataSet is named: {0}", ds.DataSetName); - foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties) - { - Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); - } - Console.WriteLine(); - foreach (DataTable dt in ds.Tables) - { - Console.WriteLine("=> {0} Table:", dt.TableName); - // Print out the column names. - for (int curCol = 0; curCol < dt.Columns.Count; curCol++) - { - Console.Write(dt.Columns[curCol].ColumnName + "\t"); - } - Console.WriteLine("\n----------------------------------"); - // Print the DataTable. - for (int curRow = 0; curRow < dt.Rows.Count; curRow++) - { - for (int curCol = 0; curCol < dt.Columns.Count; curCol++) - { - Console.Write(dt.Rows[curRow][curCol].ToString() + "\t"); - } - Console.WriteLine(); - } - } - } } } diff --git a/OpenSim/Data/SQLiteNG/SQLiteUserAccountData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs similarity index 94% rename from OpenSim/Data/SQLiteNG/SQLiteUserAccountData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs index f77159c772..27553c61eb 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { public class SQLiteUserAccountData : SQLiteGenericTableHandler, IUserAccountData { @@ -66,7 +66,7 @@ namespace OpenSim.Data.SQLiteNG if (words.Length == 1) { - cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", + cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", m_Realm, scopeID.ToString(), words[0]); } else diff --git a/OpenSim/Data/SQLiteNG/SQLiteUtils.cs b/OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs similarity index 99% rename from OpenSim/Data/SQLiteNG/SQLiteUtils.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs index 82a2e37993..095a26251f 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteUtils.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs @@ -27,9 +27,9 @@ using System; using System.Data; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// A base class for methods needed by all SQLite database classes diff --git a/OpenSim/Data/SQLiteNG/SQLiteXInventoryData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs similarity index 98% rename from OpenSim/Data/SQLiteNG/SQLiteXInventoryData.cs rename to OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs index a0c17f8fd9..5422cbf6ad 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs @@ -29,12 +29,12 @@ using System; using System.Data; using System.Reflection; using System.Collections.Generic; -using Mono.Data.Sqlite; +using Mono.Data.SqliteClient; using log4net; using OpenMetaverse; using OpenSim.Framework; -namespace OpenSim.Data.SQLiteNG +namespace OpenSim.Data.SQLiteLegacy { /// /// A MySQL Interface for the Asset Server @@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLiteNG } reader.Close(); - //CloseCommand(cmd); + CloseCommand(cmd); return perms; } diff --git a/OpenSim/Data/Tests/DataTestUtil.cs b/OpenSim/Data/Tests/DataTestUtil.cs index d211ab3b40..5393529592 100644 --- a/OpenSim/Data/Tests/DataTestUtil.cs +++ b/OpenSim/Data/Tests/DataTestUtil.cs @@ -39,7 +39,8 @@ namespace OpenSim.Data.Tests public class DataTestUtil { public const uint UNSIGNED_INTEGER_MIN = uint.MinValue; - public const uint UNSIGNED_INTEGER_MAX = uint.MaxValue; + //public const uint UNSIGNED_INTEGER_MAX = uint.MaxValue; + public const uint UNSIGNED_INTEGER_MAX = INTEGER_MAX; public const int INTEGER_MIN = int.MinValue + 1; // Postgresql requires +1 to .NET int.MinValue public const int INTEGER_MAX = int.MaxValue; diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index bbc6f78721..f49cd975f1 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -113,14 +113,14 @@ ; --- To use sqlite as region storage: ; - ; PLEASE NOTE: Unfortunately, the SQLiteNG database plugin, while necessary to use sqlite with Mono on Linux, is + ; PLEASE NOTE: Unfortunately, the current SQLite database plugin (necessary to use SQLite with Mono on Linux) is ; not compatible with the sqlite3 library installed on Mac OSX. If you're using Mono 2.4 you can still use the old sqlite - ; library by uncommenting the SQLite.dll storage plugin (and commenting out SQLiteNG). Unfortunately, the older library - ; will not work with Mono 2.6 on Mac OSX so you will either need to replace the sqlite3 system library or use MySQL instead + ; library by uncommenting the SQLiteLegacy.dll storage plugin (and commenting out SQLite.dll). Unfortunately, the older library + ; will not work with Mono 2.6 on Mac OSX so you will either need to replace the OSX sqlite3 system library or use MySQL instead ; ; You will also need to do the same thing in config-include/StandaloneCommon.ini if you are running in standalone mode - storage_plugin = "OpenSim.Data.SQLiteNG.dll" - ;storage_plugin = "OpenSim.Data.SQLite.dll" + storage_plugin = "OpenSim.Data.SQLite.dll" + ;storage_plugin = "OpenSim.Data.SQLiteLegacy.dll" storage_connection_string="URI=file:OpenSim.db,version=3"; ; --- To use MySQL storage, supply your own connection string (this is only an example): diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index 58860d157f..572c153bef 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -6,12 +6,12 @@ ; ; SQLite - Include-Storage = "config-include/storage/SQLiteNGStandalone.ini"; + Include-Storage = "config-include/storage/SQLiteStandalone.ini"; - ; Unfortunately SQLiteNG is not compatible with Mac OSX. You can still use the older - ; sqlite library if you are using Mono 2.4. Please see the notes in OpenSim.ini for sqlite + ; Unfortunately the current SQLite database plugin is not compatible with Mac OSX. You can still use the older + ; legacy sqlite library if you are using Mono 2.4. Please see the notes in OpenSim.ini (search for sqlite) ; for more details - ;Include-Storage = "config-include/storage/SQLiteStandalone.ini"; + ;Include-Storage = "config-include/storage/SQLiteLegacyStandalone.ini"; ; MySql ; Uncomment these lines if you want to use mysql storage diff --git a/bin/config-include/storage/SQLiteNGStandalone.ini b/bin/config-include/storage/SQLiteLegacyStandalone.ini similarity index 88% rename from bin/config-include/storage/SQLiteNGStandalone.ini rename to bin/config-include/storage/SQLiteLegacyStandalone.ini index ba00acaf6c..1d4dd29d60 100644 --- a/bin/config-include/storage/SQLiteNGStandalone.ini +++ b/bin/config-include/storage/SQLiteLegacyStandalone.ini @@ -1,7 +1,7 @@ ; These are the initialization settings for running OpenSim Standalone with an SQLite database [DatabaseService] - StorageProvider = "OpenSim.Data.SQLiteNG.dll" + StorageProvider = "OpenSim.Data.SQLiteLegacy.dll" [AvatarService] ConnectionString = "URI=file:avatars.db,version=3" diff --git a/prebuild.xml b/prebuild.xml index 602750ac84..9802349ae5 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2178,7 +2178,7 @@ - + ../../../bin/ @@ -2215,7 +2215,7 @@ - + ../../../bin/