aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-02 23:26:03 +0000
committerJustin Clark-Casey (justincc)2012-03-02 23:26:03 +0000
commite81b3502ef0fef2b5f449b52ea2f016861aa23f4 (patch)
tree077f5425ae8e453c23430f12ddbfeec0ecc57ed8 /OpenSim/Data
parentMerge branch 'master' into xassetservice (diff)
downloadopensim-SC_OLD-e81b3502ef0fef2b5f449b52ea2f016861aa23f4.zip
opensim-SC_OLD-e81b3502ef0fef2b5f449b52ea2f016861aa23f4.tar.gz
opensim-SC_OLD-e81b3502ef0fef2b5f449b52ea2f016861aa23f4.tar.bz2
opensim-SC_OLD-e81b3502ef0fef2b5f449b52ea2f016861aa23f4.tar.xz
Make xassetservice execute one query to retrieve the asset, not two
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs32
1 files changed, 4 insertions, 28 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index f15a9f3..0dadf5e 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -104,6 +104,8 @@ namespace OpenSim.Data.MySQL
104 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks> 104 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
105 override public AssetBase GetAsset(UUID assetID) 105 override public AssetBase GetAsset(UUID assetID)
106 { 106 {
107// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
108
107 AssetBase asset = null; 109 AssetBase asset = null;
108 lock (m_dbLock) 110 lock (m_dbLock)
109 { 111 {
@@ -114,7 +116,7 @@ namespace OpenSim.Data.MySQL
114 string hash = null; 116 string hash = null;
115 117
116 using (MySqlCommand cmd = new MySqlCommand( 118 using (MySqlCommand cmd = new MySqlCommand(
117 "SELECT name, hash, description, asset_type, local, temporary, asset_flags, creator_id FROM xassetsmeta WHERE id=?id", 119 "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id",
118 dbcon)) 120 dbcon))
119 { 121 {
120 cmd.Parameters.AddWithValue("?id", assetID.ToString()); 122 cmd.Parameters.AddWithValue("?id", assetID.ToString());
@@ -126,7 +128,7 @@ namespace OpenSim.Data.MySQL
126 if (dbReader.Read()) 128 if (dbReader.Read())
127 { 129 {
128 asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); 130 asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString());
129 hash = (string)dbReader["hash"]; 131 asset.Data = (byte[])dbReader["data"];
130 asset.Description = (string)dbReader["description"]; 132 asset.Description = (string)dbReader["description"];
131 133
132 string local = dbReader["local"].ToString(); 134 string local = dbReader["local"].ToString();
@@ -145,32 +147,6 @@ namespace OpenSim.Data.MySQL
145 m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); 147 m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message);
146 } 148 }
147 } 149 }
148
149 if (asset == null)
150 return null;
151
152 m_log.DebugFormat(
153 "[MYSQL XASSET DATA]: Looking for asset {0} {1} with hash {2}", asset.FullID, asset.Name, hash);
154
155 using (MySqlCommand cmd = new MySqlCommand(
156 "SELECT data FROM xassetsdata WHERE hash=?hash",
157 dbcon))
158 {
159 cmd.Parameters.AddWithValue("?hash", hash);
160
161 try
162 {
163 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
164 {
165 if (dbReader.Read())
166 asset.Data = (byte[])dbReader["data"];
167 }
168 }
169 catch (Exception e)
170 {
171 m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset metadata " + assetID + ": " + e.Message);
172 }
173 }
174 } 150 }
175 } 151 }
176 152