diff options
author | Justin Clark-Casey (justincc) | 2010-04-30 17:45:00 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-04-30 17:45:00 +0100 |
commit | cc67de5b86ebcebadbe2ea46872a0dc63d99cae7 (patch) | |
tree | 1607da4eee9e63fe45e0abcf05da37ae5e239d70 /OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs | |
parent | Make SQLiteNG the default since it actually does work with Mono 2.4 on Linux. (diff) | |
download | opensim-SC_OLD-cc67de5b86ebcebadbe2ea46872a0dc63d99cae7.zip opensim-SC_OLD-cc67de5b86ebcebadbe2ea46872a0dc63d99cae7.tar.gz opensim-SC_OLD-cc67de5b86ebcebadbe2ea46872a0dc63d99cae7.tar.bz2 opensim-SC_OLD-cc67de5b86ebcebadbe2ea46872a0dc63d99cae7.tar.xz |
rename SQLiteNG to SQLite and SQLite to SQLiteLegacy
this seems the least evil way forward since mono 2.6 and later will see increasing usage, and this only works with what was SQLiteNG
MAC USERS WILL NEED TO CHANGE REFERENCES TO "OpenSim.Data.SQLite.dll" to "OpenSim.Data.SQLiteLegacy.dll" in OpenSim.ini and config-include/StandaloneCommon.ini (if using standalone)
See the OpenSim.ini.example and StandaloneCommon.ini.example files for more details
This commit also temporarily changes unsigned ParentEstateID values in the OpenSim.Data.Tests to signed temporarily, since the new plugin enforces creation of signed fields in the database (which is what the SQL actually specifies). And change data columns in sqlite is a pita.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs (renamed from OpenSim/Data/SQLiteNG/SQLiteRegionData.cs) | 261 |
1 files changed, 102 insertions, 159 deletions
diff --git a/OpenSim/Data/SQLiteNG/SQLiteRegionData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs index 289d626..eb78037 100644 --- a/OpenSim/Data/SQLiteNG/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs | |||
@@ -32,13 +32,13 @@ using System.Drawing; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Data.Sqlite; | 35 | using Mono.Data.SqliteClient; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | 40 | ||
41 | namespace OpenSim.Data.SQLiteNG | 41 | namespace OpenSim.Data.SQLiteLegacy |
42 | { | 42 | { |
43 | /// <summary> | 43 | /// <summary> |
44 | /// A RegionData Interface to the SQLite database | 44 | /// A RegionData Interface to the SQLite database |
@@ -87,142 +87,119 @@ namespace OpenSim.Data.SQLiteNG | |||
87 | /// <param name="connectionString">the connection string</param> | 87 | /// <param name="connectionString">the connection string</param> |
88 | public void Initialise(string connectionString) | 88 | public void Initialise(string connectionString) |
89 | { | 89 | { |
90 | try | 90 | m_connectionString = connectionString; |
91 | { | ||
92 | m_connectionString = connectionString; | ||
93 | 91 | ||
94 | ds = new DataSet("Region"); | 92 | ds = new DataSet(); |
95 | 93 | ||
96 | m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); | 94 | m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); |
97 | m_conn = new SqliteConnection(m_connectionString); | 95 | m_conn = new SqliteConnection(m_connectionString); |
98 | m_conn.Open(); | 96 | m_conn.Open(); |
99 | 97 | ||
100 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); | ||
101 | primDa = new SqliteDataAdapter(primSelectCmd); | ||
102 | 98 | ||
103 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); | ||
104 | shapeDa = new SqliteDataAdapter(shapeSelectCmd); | ||
105 | // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); | ||
106 | 99 | ||
107 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); | 100 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); |
108 | itemsDa = new SqliteDataAdapter(itemsSelectCmd); | 101 | primDa = new SqliteDataAdapter(primSelectCmd); |
102 | // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); | ||
109 | 103 | ||
110 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); | 104 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); |
111 | terrainDa = new SqliteDataAdapter(terrainSelectCmd); | 105 | shapeDa = new SqliteDataAdapter(shapeSelectCmd); |
106 | // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); | ||
112 | 107 | ||
113 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); | 108 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); |
114 | landDa = new SqliteDataAdapter(landSelectCmd); | 109 | itemsDa = new SqliteDataAdapter(itemsSelectCmd); |
115 | 110 | ||
116 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); | 111 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); |
117 | landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); | 112 | terrainDa = new SqliteDataAdapter(terrainSelectCmd); |
118 | 113 | ||
119 | SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); | 114 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); |
120 | regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); | 115 | landDa = new SqliteDataAdapter(landSelectCmd); |
121 | // This actually does the roll forward assembly stuff | ||
122 | Assembly assem = GetType().Assembly; | ||
123 | Migration m = new Migration(m_conn, assem, "RegionStore"); | ||
124 | m.Update(); | ||
125 | 116 | ||
126 | lock (ds) | 117 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); |
127 | { | 118 | landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); |
128 | ds.Tables.Add(createPrimTable()); | ||
129 | setupPrimCommands(primDa, m_conn); | ||
130 | 119 | ||
131 | ds.Tables.Add(createShapeTable()); | 120 | SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); |
132 | setupShapeCommands(shapeDa, m_conn); | 121 | regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); |
122 | // This actually does the roll forward assembly stuff | ||
123 | Assembly assem = GetType().Assembly; | ||
124 | Migration m = new Migration(m_conn, assem, "RegionStore"); | ||
125 | m.Update(); | ||
133 | 126 | ||
134 | ds.Tables.Add(createItemsTable()); | 127 | lock (ds) |
135 | setupItemsCommands(itemsDa, m_conn); | 128 | { |
129 | ds.Tables.Add(createPrimTable()); | ||
130 | setupPrimCommands(primDa, m_conn); | ||
131 | primDa.Fill(ds.Tables["prims"]); | ||
136 | 132 | ||
137 | ds.Tables.Add(createTerrainTable()); | 133 | ds.Tables.Add(createShapeTable()); |
138 | setupTerrainCommands(terrainDa, m_conn); | 134 | setupShapeCommands(shapeDa, m_conn); |
139 | 135 | ||
140 | ds.Tables.Add(createLandTable()); | 136 | ds.Tables.Add(createItemsTable()); |
141 | setupLandCommands(landDa, m_conn); | 137 | setupItemsCommands(itemsDa, m_conn); |
138 | itemsDa.Fill(ds.Tables["primitems"]); | ||
142 | 139 | ||
143 | ds.Tables.Add(createLandAccessListTable()); | 140 | ds.Tables.Add(createTerrainTable()); |
144 | setupLandAccessCommands(landAccessListDa, m_conn); | 141 | setupTerrainCommands(terrainDa, m_conn); |
145 | 142 | ||
146 | ds.Tables.Add(createRegionSettingsTable()); | 143 | ds.Tables.Add(createLandTable()); |
147 | setupRegionSettingsCommands(regionSettingsDa, m_conn); | 144 | setupLandCommands(landDa, m_conn); |
148 | 145 | ||
149 | // WORKAROUND: This is a work around for sqlite on | 146 | ds.Tables.Add(createLandAccessListTable()); |
150 | // windows, which gets really unhappy with blob columns | 147 | setupLandAccessCommands(landAccessListDa, m_conn); |
151 | // that have no sample data in them. At some point we | ||
152 | // need to actually find a proper way to handle this. | ||
153 | try | ||
154 | { | ||
155 | primDa.Fill(ds.Tables["prims"]); | ||
156 | } | ||
157 | catch (Exception) | ||
158 | { | ||
159 | m_log.Info("[REGION DB]: Caught fill error on prims table"); | ||
160 | } | ||
161 | 148 | ||
162 | try | 149 | ds.Tables.Add(createRegionSettingsTable()); |
163 | { | 150 | |
164 | shapeDa.Fill(ds.Tables["primshapes"]); | 151 | setupRegionSettingsCommands(regionSettingsDa, m_conn); |
165 | } | ||
166 | catch (Exception) | ||
167 | { | ||
168 | m_log.Info("[REGION DB]: Caught fill error on primshapes table"); | ||
169 | } | ||
170 | 152 | ||
171 | try | 153 | // WORKAROUND: This is a work around for sqlite on |
172 | { | 154 | // windows, which gets really unhappy with blob columns |
173 | terrainDa.Fill(ds.Tables["terrain"]); | 155 | // that have no sample data in them. At some point we |
174 | } | 156 | // need to actually find a proper way to handle this. |
175 | catch (Exception) | 157 | try |
176 | { | 158 | { |
177 | m_log.Info("[REGION DB]: Caught fill error on terrain table"); | 159 | shapeDa.Fill(ds.Tables["primshapes"]); |
178 | } | 160 | } |
161 | catch (Exception) | ||
162 | { | ||
163 | m_log.Info("[REGION DB]: Caught fill error on primshapes table"); | ||
164 | } | ||
179 | 165 | ||
180 | try | 166 | try |
181 | { | 167 | { |
182 | landDa.Fill(ds.Tables["land"]); | 168 | terrainDa.Fill(ds.Tables["terrain"]); |
183 | } | 169 | } |
184 | catch (Exception) | 170 | catch (Exception) |
185 | { | 171 | { |
186 | m_log.Info("[REGION DB]: Caught fill error on land table"); | 172 | m_log.Info("[REGION DB]: Caught fill error on terrain table"); |
187 | } | 173 | } |
188 | 174 | ||
189 | try | 175 | try |
190 | { | 176 | { |
191 | landAccessListDa.Fill(ds.Tables["landaccesslist"]); | 177 | landDa.Fill(ds.Tables["land"]); |
192 | } | 178 | } |
193 | catch (Exception) | 179 | catch (Exception) |
194 | { | 180 | { |
195 | m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); | 181 | m_log.Info("[REGION DB]: Caught fill error on land table"); |
196 | } | 182 | } |
197 | 183 | ||
198 | try | 184 | try |
199 | { | 185 | { |
200 | regionSettingsDa.Fill(ds.Tables["regionsettings"]); | 186 | landAccessListDa.Fill(ds.Tables["landaccesslist"]); |
201 | } | 187 | } |
202 | catch (Exception) | 188 | catch (Exception) |
203 | { | 189 | { |
204 | m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); | 190 | m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); |
205 | } | 191 | } |
206 | 192 | ||
207 | // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values! | 193 | try |
208 | // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409 | 194 | { |
209 | // Possibly because we manually set up our own DataTables before connecting to the database | 195 | regionSettingsDa.Fill(ds.Tables["regionsettings"]); |
210 | CreateDataSetMapping(primDa, "prims"); | ||
211 | CreateDataSetMapping(shapeDa, "primshapes"); | ||
212 | CreateDataSetMapping(itemsDa, "primitems"); | ||
213 | CreateDataSetMapping(terrainDa, "terrain"); | ||
214 | CreateDataSetMapping(landDa, "land"); | ||
215 | CreateDataSetMapping(landAccessListDa, "landaccesslist"); | ||
216 | CreateDataSetMapping(regionSettingsDa, "regionsettings"); | ||
217 | } | 196 | } |
197 | catch (Exception) | ||
198 | { | ||
199 | m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); | ||
200 | } | ||
201 | return; | ||
218 | } | 202 | } |
219 | catch (Exception e) | ||
220 | { | ||
221 | m_log.Error(e); | ||
222 | Environment.Exit(23); | ||
223 | } | ||
224 | |||
225 | return; | ||
226 | } | 203 | } |
227 | 204 | ||
228 | public void Dispose() | 205 | public void Dispose() |
@@ -626,7 +603,7 @@ namespace OpenSim.Data.SQLiteNG | |||
626 | } | 603 | } |
627 | } | 604 | } |
628 | } | 605 | } |
629 | rev = Convert.ToInt32(row["Revision"]); | 606 | rev = (int) row["Revision"]; |
630 | } | 607 | } |
631 | else | 608 | else |
632 | { | 609 | { |
@@ -778,7 +755,6 @@ namespace OpenSim.Data.SQLiteNG | |||
778 | /// </summary> | 755 | /// </summary> |
779 | public void Commit() | 756 | public void Commit() |
780 | { | 757 | { |
781 | m_log.Debug("[SQLITE]: Starting commit"); | ||
782 | lock (ds) | 758 | lock (ds) |
783 | { | 759 | { |
784 | primDa.Update(ds, "prims"); | 760 | primDa.Update(ds, "prims"); |
@@ -793,11 +769,18 @@ namespace OpenSim.Data.SQLiteNG | |||
793 | { | 769 | { |
794 | regionSettingsDa.Update(ds, "regionsettings"); | 770 | regionSettingsDa.Update(ds, "regionsettings"); |
795 | } | 771 | } |
796 | catch (SqliteException SqlEx) | 772 | catch (SqliteExecutionException SqlEx) |
797 | { | 773 | { |
798 | throw new Exception( | 774 | if (SqlEx.Message.Contains("logic error")) |
799 | "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!", | 775 | { |
800 | SqlEx); | 776 | throw new Exception( |
777 | "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!", | ||
778 | SqlEx); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | throw SqlEx; | ||
783 | } | ||
801 | } | 784 | } |
802 | ds.AcceptChanges(); | 785 | ds.AcceptChanges(); |
803 | } | 786 | } |
@@ -819,15 +802,6 @@ namespace OpenSim.Data.SQLiteNG | |||
819 | * | 802 | * |
820 | **********************************************************************/ | 803 | **********************************************************************/ |
821 | 804 | ||
822 | protected void CreateDataSetMapping(IDataAdapter da, string tableName) | ||
823 | { | ||
824 | ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); | ||
825 | foreach (DataColumn col in ds.Tables[tableName].Columns) | ||
826 | { | ||
827 | dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); | ||
828 | } | ||
829 | } | ||
830 | |||
831 | /// <summary> | 805 | /// <summary> |
832 | /// | 806 | /// |
833 | /// </summary> | 807 | /// </summary> |
@@ -1990,7 +1964,6 @@ namespace OpenSim.Data.SQLiteNG | |||
1990 | sql += ") values (:"; | 1964 | sql += ") values (:"; |
1991 | sql += String.Join(", :", cols); | 1965 | sql += String.Join(", :", cols); |
1992 | sql += ")"; | 1966 | sql += ")"; |
1993 | m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql); | ||
1994 | SqliteCommand cmd = new SqliteCommand(sql); | 1967 | SqliteCommand cmd = new SqliteCommand(sql); |
1995 | 1968 | ||
1996 | // this provides the binding for all our parameters, so | 1969 | // this provides the binding for all our parameters, so |
@@ -2286,36 +2259,6 @@ namespace OpenSim.Data.SQLiteNG | |||
2286 | return DbType.String; | 2259 | return DbType.String; |
2287 | } | 2260 | } |
2288 | } | 2261 | } |
2289 | |||
2290 | static void PrintDataSet(DataSet ds) | ||
2291 | { | ||
2292 | // Print out any name and extended properties. | ||
2293 | Console.WriteLine("DataSet is named: {0}", ds.DataSetName); | ||
2294 | foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties) | ||
2295 | { | ||
2296 | Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); | ||
2297 | } | ||
2298 | Console.WriteLine(); | ||
2299 | foreach (DataTable dt in ds.Tables) | ||
2300 | { | ||
2301 | Console.WriteLine("=> {0} Table:", dt.TableName); | ||
2302 | // Print out the column names. | ||
2303 | for (int curCol = 0; curCol < dt.Columns.Count; curCol++) | ||
2304 | { | ||
2305 | Console.Write(dt.Columns[curCol].ColumnName + "\t"); | ||
2306 | } | ||
2307 | Console.WriteLine("\n----------------------------------"); | ||
2308 | // Print the DataTable. | ||
2309 | for (int curRow = 0; curRow < dt.Rows.Count; curRow++) | ||
2310 | { | ||
2311 | for (int curCol = 0; curCol < dt.Columns.Count; curCol++) | ||
2312 | { | ||
2313 | Console.Write(dt.Rows[curRow][curCol].ToString() + "\t"); | ||
2314 | } | ||
2315 | Console.WriteLine(); | ||
2316 | } | ||
2317 | } | ||
2318 | } | ||
2319 | 2262 | ||
2320 | } | 2263 | } |
2321 | } | 2264 | } |