diff options
author | BlueWall | 2014-10-10 19:24:46 -0400 |
---|---|---|
committer | BlueWall | 2014-10-10 19:58:07 -0400 |
commit | 7af878a4f48f1748750d200baa4e59ccbcf75c8e (patch) | |
tree | 8a26d0dcf549215133e123806be57e1ab4314a57 /OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |
parent | Change name of just added OSSL osForceSit() to osForceOtherSit() (diff) | |
download | opensim-SC-7af878a4f48f1748750d200baa4e59ccbcf75c8e.zip opensim-SC-7af878a4f48f1748750d200baa4e59ccbcf75c8e.tar.gz opensim-SC-7af878a4f48f1748750d200baa4e59ccbcf75c8e.tar.bz2 opensim-SC-7af878a4f48f1748750d200baa4e59ccbcf75c8e.tar.xz |
Fix some errors in PgSQL XAssets by changing some data types. Also make sql query syntax more in line with the PgSQL AssetData implementation.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLXAssetData.cs | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs index c6cebff..a8a9e38 100644 --- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |||
@@ -56,6 +56,7 @@ namespace OpenSim.Data.PGSQL | |||
56 | private const int DaysBetweenAccessTimeUpdates = 30; | 56 | private const int DaysBetweenAccessTimeUpdates = 30; |
57 | 57 | ||
58 | private bool m_enableCompression = false; | 58 | private bool m_enableCompression = false; |
59 | private PGSQLManager m_database; | ||
59 | private string m_connectionString; | 60 | private string m_connectionString; |
60 | private object m_dbLock = new object(); | 61 | private object m_dbLock = new object(); |
61 | 62 | ||
@@ -92,6 +93,7 @@ namespace OpenSim.Data.PGSQL | |||
92 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | 93 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); |
93 | 94 | ||
94 | m_connectionString = connect; | 95 | m_connectionString = connect; |
96 | m_database = new PGSQLManager(m_connectionString); | ||
95 | 97 | ||
96 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | 98 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) |
97 | { | 99 | { |
@@ -151,7 +153,12 @@ namespace OpenSim.Data.PGSQL | |||
151 | { | 153 | { |
152 | if (dbReader.Read()) | 154 | if (dbReader.Read()) |
153 | { | 155 | { |
154 | asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); | 156 | asset = new AssetBase( |
157 | assetID, | ||
158 | (string)dbReader["Name"], | ||
159 | Convert.ToSByte(dbReader["AssetType"]), | ||
160 | dbReader["CreatorID"].ToString()); | ||
161 | |||
155 | asset.Data = (byte[])dbReader["Data"]; | 162 | asset.Data = (byte[])dbReader["Data"]; |
156 | asset.Description = (string)dbReader["Description"]; | 163 | asset.Description = (string)dbReader["Description"]; |
157 | 164 | ||
@@ -249,17 +256,19 @@ namespace OpenSim.Data.PGSQL | |||
249 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", | 256 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", |
250 | // asset.ID, asset.Name, hash, compressedData.Length); | 257 | // asset.ID, asset.Name, hash, compressedData.Length); |
251 | 258 | ||
259 | m_log.DebugFormat("[XASSET DB]: Hash Info {0} {1}", hash, hash.Length); | ||
260 | |||
252 | try | 261 | try |
253 | { | 262 | { |
254 | using (NpgsqlCommand cmd = | 263 | using (NpgsqlCommand cmd = |
255 | new NpgsqlCommand( | 264 | new NpgsqlCommand( |
256 | @"insert INTO XAssetsMeta(""ID"", ""Hash"", ""Name"", ""Description"", ""AssetType"", ""Local"", ""Temporary"", ""CreateTime"", ""AccessTime"", ""AssetFlags"", ""CreatorID"") | 265 | @"insert INTO XAssetsMeta(""ID"", ""Hash"", ""Name"", ""Description"", " + " \"AssetType\" " + @", ""Local"", ""Temporary"", ""CreateTime"", ""AccessTime"", ""AssetFlags"", ""CreatorID"") |
257 | Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID | 266 | Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID |
258 | where not exists( Select ""ID"" from XAssetsMeta where ""ID"" = :ID ; | 267 | where not exists( Select ""ID"" from XAssetsMeta where ""ID"" = :ID); |
259 | 268 | ||
260 | update XAssetsMeta | 269 | update XAssetsMeta |
261 | set ""ID"" = :ID, ""Hash"" = :Hash, ""Name"" = :Name, ""Description"" = :Description, | 270 | set ""ID"" = :ID, ""Hash"" = :Hash, ""Name"" = :Name, ""Description"" = :Description, " + |
262 | ""AssetType"" = :AssetType, ""Local"" = :Local, ""Temporary"" = :Temporary, ""CreateTime"" = :CreateTime, | 271 | "\"AssetType\" " + @" = :AssetType, ""Local"" = :Local, ""Temporary"" = :Temporary, ""CreateTime"" = :CreateTime, |
263 | ""AccessTime"" = :AccessTime, ""AssetFlags"" = :AssetFlags, ""CreatorID"" = :CreatorID | 272 | ""AccessTime"" = :AccessTime, ""AssetFlags"" = :AssetFlags, ""CreatorID"" = :CreatorID |
264 | where ""ID"" = :ID; | 273 | where ""ID"" = :ID; |
265 | ", | 274 | ", |
@@ -267,17 +276,29 @@ namespace OpenSim.Data.PGSQL | |||
267 | { | 276 | { |
268 | // create unix epoch time | 277 | // create unix epoch time |
269 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 278 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
270 | cmd.Parameters.AddWithValue("ID", asset.ID); | 279 | cmd.Parameters.Add(m_database.CreateParameter("ID", asset.ID)); |
271 | cmd.Parameters.AddWithValue("Hash", hash); | 280 | // cmd.Parameters.AddWithValue("ID", asset.ID); |
272 | cmd.Parameters.AddWithValue("Name", assetName); | 281 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); |
273 | cmd.Parameters.AddWithValue("Description", assetDescription); | 282 | // cmd.Parameters.AddWithValue("Hash", hash); |
274 | cmd.Parameters.AddWithValue("AssetType", asset.Type); | 283 | cmd.Parameters.Add(m_database.CreateParameter("Name", assetName)); |
275 | cmd.Parameters.AddWithValue("Local", asset.Local); | 284 | // cmd.Parameters.AddWithValue("Name", assetName); |
276 | cmd.Parameters.AddWithValue("Temporary", asset.Temporary); | 285 | cmd.Parameters.Add(m_database.CreateParameter("Description", assetDescription)); |
277 | cmd.Parameters.AddWithValue("CreateTime", now); | 286 | // cmd.Parameters.AddWithValue("Description", assetDescription); |
278 | cmd.Parameters.AddWithValue("AccessTime", now); | 287 | cmd.Parameters.Add(m_database.CreateParameter("AssetType", asset.Type)); |
279 | cmd.Parameters.AddWithValue("CreatorID", asset.Metadata.CreatorID); | 288 | // cmd.Parameters.AddWithValue("AssetType", asset.Type); |
280 | cmd.Parameters.AddWithValue("AssetFlags", (int)asset.Flags); | 289 | cmd.Parameters.Add(m_database.CreateParameter("Local", asset.Local)); |
290 | // cmd.Parameters.AddWithValue("Local", asset.Local); | ||
291 | cmd.Parameters.Add(m_database.CreateParameter("Temporary", asset.Temporary)); | ||
292 | // cmd.Parameters.AddWithValue("Temporary", asset.Temporary); | ||
293 | cmd.Parameters.Add(m_database.CreateParameter("CreateTime", now)); | ||
294 | // cmd.Parameters.AddWithValue("CreateTime", now); | ||
295 | cmd.Parameters.Add(m_database.CreateParameter("AccessTime", now)); | ||
296 | // cmd.Parameters.AddWithValue("AccessTime", now); | ||
297 | cmd.Parameters.Add(m_database.CreateParameter("CreatorID", asset.Metadata.CreatorID)); | ||
298 | // cmd.Parameters.AddWithValue("CreatorID", asset.Metadata.CreatorID); | ||
299 | cmd.Parameters.Add(m_database.CreateParameter("AssetFlags", (int)asset.Flags)); | ||
300 | // cmd.Parameters.AddWithValue("AssetFlags", (int)asset.Flags); | ||
301 | |||
281 | cmd.ExecuteNonQuery(); | 302 | cmd.ExecuteNonQuery(); |
282 | } | 303 | } |
283 | } | 304 | } |
@@ -300,8 +321,10 @@ namespace OpenSim.Data.PGSQL | |||
300 | @"INSERT INTO XAssetsData(""Hash"", ""Data"") VALUES(:Hash, :Data)", | 321 | @"INSERT INTO XAssetsData(""Hash"", ""Data"") VALUES(:Hash, :Data)", |
301 | dbcon)) | 322 | dbcon)) |
302 | { | 323 | { |
303 | cmd.Parameters.AddWithValue("Hash", hash); | 324 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); |
304 | cmd.Parameters.AddWithValue("Data", asset.Data); | 325 | // cmd.Parameters.AddWithValue("Hash", hash); |
326 | cmd.Parameters.Add(m_database.CreateParameter("Data", asset.Data)); | ||
327 | // cmd.Parameters.AddWithValue("Data", asset.Data); | ||
305 | cmd.ExecuteNonQuery(); | 328 | cmd.ExecuteNonQuery(); |
306 | } | 329 | } |
307 | } | 330 | } |
@@ -351,8 +374,10 @@ namespace OpenSim.Data.PGSQL | |||
351 | using (cmd) | 374 | using (cmd) |
352 | { | 375 | { |
353 | // create unix epoch time | 376 | // create unix epoch time |
354 | cmd.Parameters.AddWithValue("ID", assetMetadata.ID); | 377 | cmd.Parameters.Add(m_database.CreateParameter("ID", assetMetadata.ID)); |
355 | cmd.Parameters.AddWithValue("AccessTime", (int)Utils.DateTimeToUnixTime(now)); | 378 | // cmd.Parameters.AddWithValue("ID", assetMetadata.ID); |
379 | cmd.Parameters.Add(m_database.CreateParameter("AccessTime", (int)Utils.DateTimeToUnixTime(now))); | ||
380 | // cmd.Parameters.AddWithValue("AccessTime", (int)Utils.DateTimeToUnixTime(now)); | ||
356 | cmd.ExecuteNonQuery(); | 381 | cmd.ExecuteNonQuery(); |
357 | } | 382 | } |
358 | } | 383 | } |
@@ -518,7 +543,7 @@ namespace OpenSim.Data.PGSQL | |||
518 | AssetMetadata metadata = new AssetMetadata(); | 543 | AssetMetadata metadata = new AssetMetadata(); |
519 | metadata.Name = (string)dbReader["Name"]; | 544 | metadata.Name = (string)dbReader["Name"]; |
520 | metadata.Description = (string)dbReader["Description"]; | 545 | metadata.Description = (string)dbReader["Description"]; |
521 | metadata.Type = (sbyte)dbReader["AssetType"]; | 546 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); |
522 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. | 547 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. |
523 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); | 548 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
524 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); | 549 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); |