diff options
author | BlueWall | 2014-10-15 17:28:51 -0400 |
---|---|---|
committer | BlueWall | 2014-10-15 17:28:51 -0400 |
commit | 8a93d97320f8151ca4d5ff2d83e25a7ff5d41499 (patch) | |
tree | c826a4c99448af01dec4bfc4354a9c45fefdaa9a /OpenSim/Data | |
parent | Fix over zealous chopping of text when editing (pilot error) (diff) | |
download | opensim-SC_OLD-8a93d97320f8151ca4d5ff2d83e25a7ff5d41499.zip opensim-SC_OLD-8a93d97320f8151ca4d5ff2d83e25a7ff5d41499.tar.gz opensim-SC_OLD-8a93d97320f8151ca4d5ff2d83e25a7ff5d41499.tar.bz2 opensim-SC_OLD-8a93d97320f8151ca4d5ff2d83e25a7ff5d41499.tar.xz |
Touchup PgSQL XAssets adapter
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLXAssetData.cs | 29 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/Resources/XAssetStore.migrations | 10 |
2 files changed, 28 insertions, 11 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs index 967aeba..4f682f0 100644 --- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |||
@@ -145,7 +145,7 @@ namespace OpenSim.Data.PGSQL | |||
145 | JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", | 145 | JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", |
146 | dbcon)) | 146 | dbcon)) |
147 | { | 147 | { |
148 | cmd.Parameters.AddWithValue("ID", assetID.ToString()); | 148 | cmd.Parameters.Add(m_database.CreateParameter("ID", assetID)); |
149 | 149 | ||
150 | try | 150 | try |
151 | { | 151 | { |
@@ -252,6 +252,9 @@ namespace OpenSim.Data.PGSQL | |||
252 | 252 | ||
253 | byte[] hash = hasher.ComputeHash(asset.Data); | 253 | byte[] hash = hasher.ComputeHash(asset.Data); |
254 | 254 | ||
255 | UUID asset_id; | ||
256 | UUID.TryParse(asset.ID, out asset_id); | ||
257 | |||
255 | // m_log.DebugFormat( | 258 | // m_log.DebugFormat( |
256 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", | 259 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", |
257 | // asset.ID, asset.Name, hash, compressedData.Length); | 260 | // asset.ID, asset.Name, hash, compressedData.Length); |
@@ -260,21 +263,22 @@ namespace OpenSim.Data.PGSQL | |||
260 | { | 263 | { |
261 | using (NpgsqlCommand cmd = | 264 | using (NpgsqlCommand cmd = |
262 | new NpgsqlCommand( | 265 | new NpgsqlCommand( |
263 | @"insert INTO XAssetsMeta(id, hash, name, description, " + " \"AssetType\" " + @", local, temporary, create_time, access_time, asset_flags, creatorid) | 266 | @"insert INTO XAssetsMeta(id, hash, name, description, ""AssetType"", local, temporary, create_time, access_time, asset_flags, creatorid) |
264 | Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID | 267 | Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID |
265 | where not exists( Select id from XAssetsMeta where id = :ID); | 268 | where not exists( Select id from XAssetsMeta where id = :ID); |
266 | 269 | ||
267 | update XAssetsMeta | 270 | update XAssetsMeta |
268 | set id = :ID, hash = :Hash, name = :Name, description = :Description, " + | 271 | set id = :ID, hash = :Hash, name = :Name, description = :Description, |
269 | "\"AssetType\" " + @" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, | 272 | ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, |
270 | access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID | 273 | access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID |
271 | where id = :ID; | 274 | where id = :ID; |
272 | ", | 275 | ", |
273 | dbcon)) | 276 | dbcon)) |
274 | { | 277 | { |
278 | |||
275 | // create unix epoch time | 279 | // create unix epoch time |
276 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 280 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
277 | cmd.Parameters.Add(m_database.CreateParameter("ID", asset.ID)); | 281 | cmd.Parameters.Add(m_database.CreateParameter("ID", asset_id)); |
278 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); | 282 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); |
279 | cmd.Parameters.Add(m_database.CreateParameter("Name", assetName)); | 283 | cmd.Parameters.Add(m_database.CreateParameter("Name", assetName)); |
280 | cmd.Parameters.Add(m_database.CreateParameter("Description", assetDescription)); | 284 | cmd.Parameters.Add(m_database.CreateParameter("Description", assetDescription)); |
@@ -356,10 +360,13 @@ namespace OpenSim.Data.PGSQL | |||
356 | 360 | ||
357 | try | 361 | try |
358 | { | 362 | { |
363 | UUID asset_id; | ||
364 | UUID.TryParse(assetMetadata.ID, out asset_id); | ||
365 | |||
359 | using (cmd) | 366 | using (cmd) |
360 | { | 367 | { |
361 | // create unix epoch time | 368 | // create unix epoch time |
362 | cmd.Parameters.Add(m_database.CreateParameter("id", assetMetadata.ID)); | 369 | cmd.Parameters.Add(m_database.CreateParameter("id", asset_id)); |
363 | cmd.Parameters.Add(m_database.CreateParameter("access_time", (int)Utils.DateTimeToUnixTime(now))); | 370 | cmd.Parameters.Add(m_database.CreateParameter("access_time", (int)Utils.DateTimeToUnixTime(now))); |
364 | cmd.ExecuteNonQuery(); | 371 | cmd.ExecuteNonQuery(); |
365 | } | 372 | } |
@@ -390,7 +397,7 @@ namespace OpenSim.Data.PGSQL | |||
390 | 397 | ||
391 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT hash FROM XAssetsData WHERE hash=:Hash", dbcon)) | 398 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT hash FROM XAssetsData WHERE hash=:Hash", dbcon)) |
392 | { | 399 | { |
393 | cmd.Parameters.AddWithValue("hash", hash); | 400 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); |
394 | 401 | ||
395 | try | 402 | try |
396 | { | 403 | { |
@@ -469,7 +476,7 @@ namespace OpenSim.Data.PGSQL | |||
469 | dbcon.Open(); | 476 | dbcon.Open(); |
470 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT id FROM XAssetsMeta WHERE id=:ID", dbcon)) | 477 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT id FROM XAssetsMeta WHERE id=:ID", dbcon)) |
471 | { | 478 | { |
472 | cmd.Parameters.AddWithValue("id", uuid.ToString()); | 479 | cmd.Parameters.Add(m_database.CreateParameter("id", uuid)); |
473 | 480 | ||
474 | try | 481 | try |
475 | { | 482 | { |
@@ -514,8 +521,8 @@ namespace OpenSim.Data.PGSQL | |||
514 | NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid | 521 | NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid |
515 | FROM XAssetsMeta | 522 | FROM XAssetsMeta |
516 | LIMIT :start, :count", dbcon); | 523 | LIMIT :start, :count", dbcon); |
517 | cmd.Parameters.AddWithValue("start", start); | 524 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); |
518 | cmd.Parameters.AddWithValue("count", count); | 525 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); |
519 | 526 | ||
520 | try | 527 | try |
521 | { | 528 | { |
@@ -563,7 +570,7 @@ namespace OpenSim.Data.PGSQL | |||
563 | 570 | ||
564 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"delete from XAssetsMeta where id=:ID", dbcon)) | 571 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"delete from XAssetsMeta where id=:ID", dbcon)) |
565 | { | 572 | { |
566 | cmd.Parameters.AddWithValue(id, id); | 573 | cmd.Parameters.Add(m_database.CreateParameter(id, id)); |
567 | cmd.ExecuteNonQuery(); | 574 | cmd.ExecuteNonQuery(); |
568 | } | 575 | } |
569 | 576 | ||
diff --git a/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations b/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations index 8fb3656..096ecc4 100644 --- a/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations | |||
@@ -81,4 +81,14 @@ ALTER TABLE xassetsdata DROP COLUMN hash; | |||
81 | ALTER TABLE xassetsdata ADD COLUMN hash bytea NOT NULL; | 81 | ALTER TABLE xassetsdata ADD COLUMN hash bytea NOT NULL; |
82 | ALTER TABLE xassetsdata ADD PRIMARY KEY (hash); | 82 | ALTER TABLE xassetsdata ADD PRIMARY KEY (hash); |
83 | 83 | ||
84 | COMMIT; | ||
85 | |||
86 | :VERSION 5 | ||
87 | |||
88 | BEGIN; | ||
89 | |||
90 | ALTER TABLE xassetsmeta ALTER COLUMN id SET DATA TYPE uuid USING id::uuid; | ||
91 | ALTER TABLE xassetsmeta ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea; | ||
92 | ALTER TABLE xassetsdata ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea; | ||
93 | |||
84 | COMMIT; \ No newline at end of file | 94 | COMMIT; \ No newline at end of file |