Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

464 lines
12 KiB

  1. /****** Object: Stored Procedure dbo.sp_AddCrashInstance2 Script Date: 5/17/2002 4:39:50 PM ******/
  2. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddCrashInstance2]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3. drop procedure [dbo].[sp_AddCrashInstance2]
  4. GO
  5. /****** Object: Stored Procedure dbo.sp_CheckCrashExists Script Date: 5/17/2002 4:39:50 PM ******/
  6. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CheckCrashExists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  7. drop procedure [dbo].[sp_CheckCrashExists]
  8. GO
  9. /****** Object: Stored Procedure dbo.sp_GetIntBucket Script Date: 5/17/2002 4:39:50 PM ******/
  10. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_GetIntBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  11. drop procedure [dbo].[sp_GetIntBucket]
  12. GO
  13. /****** Object: Stored Procedure dbo.sp_UpdateCount Script Date: 5/17/2002 4:39:50 PM ******/
  14. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_UpdateCount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  15. drop procedure [dbo].[sp_UpdateCount]
  16. GO
  17. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_RetriveSRBuckets]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  18. drop procedure [dbo].[sp_RetriveSRBuckets]
  19. GO
  20. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_LinkCrashSR]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  21. drop procedure [dbo].[sp_LinkCrashSR]
  22. GO
  23. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CheckSRExists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  24. drop procedure [dbo].[sp_CheckSRExists]
  25. GO
  26. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_GetBucketComments]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  27. drop procedure [dbo].[sp_GetBucketComments]
  28. GO
  29. SET QUOTED_IDENTIFIER OFF
  30. GO
  31. SET ANSI_NULLS ON
  32. GO
  33. /****** Object: Stored Procedure dbo.sp_AddCrashInstance2 Script Date: 12/14/2001 5:00:04 PM ******/
  34. /*
  35. Adds a crash instance to CrashDb
  36. Returns isBucket, igBucket if successfull
  37. 5/24 - solson - Added FullDump tracking code
  38. */
  39. CREATE PROCEDURE sp_AddCrashInstance2 (
  40. @ip_retriageBucket tinyint,
  41. @ip_BucketId varchar(100),
  42. @ip_Path nvarchar(128),
  43. @ip_FollowUp varchar(50),
  44. @ip_BuildNo int,
  45. @ip_Source int,
  46. @ip_CpuId bigint,
  47. @ip_OverClocked bit,
  48. @ip_Guid uniqueidentifier,
  49. @ip_gBucketId varchar(100),
  50. @ip_DriverName varchar (100),
  51. @ip_Type int,
  52. @ip_UpTime int,
  53. @ip_SKU smallint,
  54. @ip_LangId smallint,
  55. @ip_OemId int
  56. )
  57. AS
  58. BEGIN
  59. DECLARE @i_sBucket int
  60. DECLARE @i_gBucket int
  61. DECLARE @i_Followup int
  62. DECLARE @i_OldFollowup int
  63. DECLARE @i_DriverName int
  64. DECLARE @i_OldDriverName int
  65. DECLARE @bFullDumpFlag bit
  66. SET NOCOUNT ON
  67. --Solson 5/24 : Set a fulldump flag if we have a fulldump
  68. IF( @ip_Type = 5 or @ip_Type = 6 or @ip_Type = 7 )
  69. SET @bFullDumpFlag = 1
  70. ELSE
  71. SET @bFullDumpFlag = 0
  72. -- Find the specific bucket
  73. SELECT @i_sBucket = iBucket,
  74. @i_OldFollowup = iFollowup,
  75. @i_OldDriverName = iDriverName
  76. FROM BucketToInt WHERE BucketId = @ip_BucketId
  77. -- If the specifc bucket does not exist, or we want to update the
  78. -- fields
  79. IF ( @i_sBucket IS NULL OR @ip_retriageBucket = 1)
  80. BEGIN
  81. SELECT @i_Followup = iFollowup FROM FollowupIds
  82. WHERE Followup = @ip_FollowUp
  83. --get (or add) the followup information.
  84. -- IF NOT EXISTS (SELECT * FROM FollowupIds
  85. -- WHERE Followup = @ip_FollowUp)
  86. if (@i_Followup is null)
  87. BEGIN
  88. INSERT INTO FollowupIds (Followup, iGroup) VALUES (@ip_FollowUp, NULL)
  89. SELECT @i_Followup = @@IDENTITY
  90. END
  91. -- ELSE
  92. -- BEGIN
  93. -- SELECT @i_Followup = iFollowup FROM FollowupIds
  94. -- WHERE Followup = @ip_FollowUp
  95. -- END
  96. --get (or add) the driver name.
  97. SELECT @i_DriverName = iDriverName FROM DrNames
  98. WHERE DriverName = @ip_DriverName
  99. if (@i_DriverName is null)
  100. -- IF NOT EXISTS (SELECT * FROM DrNames
  101. -- WHERE DriverName = @ip_DriverName)
  102. BEGIN
  103. INSERT INTO DrNames (DriverName)
  104. VALUES (@ip_DriverName)
  105. SELECT @i_DriverName = @@IDENTITY
  106. END
  107. -- ELSE
  108. -- BEGIN
  109. -- SELECT @i_DriverName = iDriverName FROM DrNames
  110. -- WHERE DriverName = @ip_DriverName
  111. -- END
  112. END
  113. IF ( @i_sBucket IS NULL)
  114. BEGIN
  115. INSERT INTO BucketToInt (BucketId, iFollowup, iDriverName, Platform) -- added platfrom param sbeer 02/20/02
  116. VALUES (@ip_BucketId, @i_Followup, @i_DriverName, @ip_Type)
  117. SELECT @i_sBucket = @@IDENTITY
  118. END
  119. ELSE
  120. BEGIN
  121. -- Bucket exists in bucket table. Update it if necessary
  122. IF @ip_RetriageBucket = 1
  123. -- BEGIN
  124. -- IF ( (@i_OldFollowup != @i_Followup) OR
  125. -- (@i_OldDriverName != @i_DriverName) )
  126. BEGIN
  127. UPDATE BucketToInt
  128. SET iFollowup = @i_Followup, iDriverName = @i_DriverName, Platform = @ip_Type -- added platfrom param sbeer 02/20/02
  129. WHERE iBucket = @i_sBucket
  130. END
  131. -- END
  132. END
  133. -- Add generic bucket
  134. SELECT @i_gBucket = iBucket FROM BucketToInt
  135. WHERE BucketId = @ip_gBucketId
  136. IF (@i_gBucket IS NULL)
  137. BEGIN
  138. INSERT BucketToInt ( BucketID, iFollowUp,Platform) VALUES (@ip_gBucketId,0,@ip_Type) --added explicit column names solson 02/14/02
  139. SELECT @i_gBucket = @@IDENTITY
  140. END
  141. -- Add the Crash Instance to the crash instance table and the mapping
  142. -- table
  143. IF NOT EXISTS (SELECT GUID FROM CrashInstances
  144. WHERE GUID = @ip_Guid)
  145. BEGIN
  146. INSERT INTO CrashInstances ( bFullDump, BuildNo, CpuID, sBucket, gBucket, EntryDate, Source, GUID, SKU, Uptime, OEMID )
  147. VALUES ( @bFullDumpFlag,
  148. @ip_BuildNo, @ip_CpuId,
  149. @i_sBucket,
  150. @i_gBucket,
  151. GetDate(),
  152. @ip_Source,
  153. @ip_Guid,
  154. @ip_SKU,
  155. @ip_UpTime,
  156. @ip_OemId
  157. )
  158. INSERT INTO FilePath (Guid, FilePath)
  159. VALUES (@ip_Guid, @ip_Path)
  160. END
  161. ELSE
  162. BEGIN
  163. IF (@ip_retriageBucket = 1)
  164. BEGIN
  165. UPDATE CrashInstances
  166. SET sBucket = @i_sBucket, gBucket = @i_gBucket
  167. WHERE GUID = @ip_Guid
  168. END
  169. END
  170. SET NOCOUNT OFF
  171. SELECT @i_sBucket AS sBucket, @i_gBucket AS gBucket
  172. END
  173. GO
  174. SET QUOTED_IDENTIFIER OFF
  175. GO
  176. SET ANSI_NULLS ON
  177. GO
  178. SET QUOTED_IDENTIFIER ON
  179. GO
  180. SET ANSI_NULLS ON
  181. GO
  182. /****** Object: Stored Procedure dbo.sp_CheckCrashExists Script Date: 12/14/2001 5:00:04 PM ******/
  183. CREATE PROCEDURE sp_CheckCrashExists
  184. @guid AS uniqueidentifier
  185. AS
  186. BEGIN
  187. DECLARE @retval as int
  188. SET @retval = 0
  189. IF EXISTS (SELECT * FROM CrashInstances WHERE GUID = @Guid)
  190. BEGIN
  191. SET @retval = 1
  192. END
  193. SELECT @retval AS CrashExists
  194. END
  195. GO
  196. SET QUOTED_IDENTIFIER OFF
  197. GO
  198. SET ANSI_NULLS ON
  199. GO
  200. SET QUOTED_IDENTIFIER ON
  201. GO
  202. SET ANSI_NULLS ON
  203. GO
  204. /****** Object: Stored Procedure dbo.sp_GetIntBucket Script Date: 5/17/2002 4:39:50 PM ******/
  205. CREATE PROCEDURE sp_GetIntBucket
  206. @i_BucketId1 as varchar(256),
  207. @i_BucketId2 as varchar(256)
  208. AS
  209. BEGIN
  210. DECLARE @id1 as int
  211. DECLARE @id2 as int
  212. SELECT @id1 = iBucket FROM BucketToInt
  213. WHERE BucketId = @i_BucketId1
  214. SELECT @id2 = iBucket FROM BucketToInt
  215. WHERE BucketId = @i_BucketId2
  216. SELECT @id1 AS iBucket1, @id2 AS iBucket2
  217. END
  218. GO
  219. SET QUOTED_IDENTIFIER OFF
  220. GO
  221. SET ANSI_NULLS ON
  222. GO
  223. SET QUOTED_IDENTIFIER ON
  224. GO
  225. SET ANSI_NULLS ON
  226. GO
  227. /****** Object: Stored Procedure dbo.sp_UpdateCount Script Date: 5/17/2002 4:39:50 PM ******/
  228. -- 5/24 Solson : Added Buildno parameter and handling
  229. CREATE PROCEDURE sp_UpdateCount (
  230. @BucketID varchar(100),
  231. @BuildNo int = 0,
  232. @EntryDate datetime = 0,
  233. @iBucket int = 0
  234. )
  235. AS
  236. IF ( @EntryDate = 0 )
  237. SET @EntryDate = GetDate()
  238. IF ( @iBucket != 0 )
  239. SELECT @BucketID = BucketID FROM BucketToInt where iBucket = @iBucket
  240. SET @EntryDate = CAST( CAST( @EntryDate as Varchar(11) ) as DateTime)
  241. BEGIN
  242. IF EXISTS (SELECT * FROM BucketCounts WHERE BucketId = @BucketID and HitDate = @EntryDate and BuildNo = @BuildNo )
  243. BEGIN
  244. UPDATE BucketCounts
  245. SET HitDate=@EntryDate, HitCount=HitCount+1
  246. WHERE BucketId = @BucketID and HitDate = @EntryDate and BuildNo = @BuildNo
  247. END
  248. ELSE
  249. BEGIN
  250. INSERT INTO BucketCounts ( HitCount, BuildNo, HitDate, BucketID )
  251. VALUES ( 1, @BuildNo, @EntryDate, @BucketID)
  252. END
  253. SELECT @BucketID as BucketID
  254. END
  255. GO
  256. SET QUOTED_IDENTIFIER OFF
  257. GO
  258. SET ANSI_NULLS ON
  259. GO
  260. SET QUOTED_IDENTIFIER OFF
  261. GO
  262. SET ANSI_NULLS OFF
  263. GO
  264. CREATE PROCEDURE dbo.sp_RetriveSRBuckets
  265. @strSR varchar(20)
  266. AS
  267. BEGIN
  268. DECLARE @i_sBucket int
  269. DECLARE @i_gBucket int
  270. DECLARE @str_sBucket varchar(100)
  271. DECLARE @str_gBucket varchar(100)
  272. SELECT @i_sBucket = sBucket, @i_gBucket = gBucket
  273. FROM PssSR left join CrashInstances as ci ON PssSr.CrashGUID = ci.GUID
  274. WHERE PssSR.SR = @strSR
  275. SELECT @str_sBucket=BucketId FROM BucketToInt WHERE iBucket = @i_sBucket
  276. SELECT @str_gBucket=BucketId FROM BucketToInt WHERE iBucket = @i_gBucket
  277. SELECT @str_sBucket AS sBucket, @str_gBucket AS gBucket
  278. END
  279. GO
  280. SET QUOTED_IDENTIFIER OFF
  281. GO
  282. SET ANSI_NULLS ON
  283. GO
  284. SET QUOTED_IDENTIFIER OFF
  285. GO
  286. SET ANSI_NULLS OFF
  287. GO
  288. CREATE PROCEDURE dbo.sp_LinkCrashSR
  289. @strSR varchar(20),
  290. @CrashGUID uniqueidentifier
  291. AS
  292. BEGIN
  293. INSERT into PssSR VALUES (@strSR, @CrashGUID)
  294. SELECT 1
  295. END
  296. GO
  297. SET QUOTED_IDENTIFIER OFF
  298. GO
  299. SET ANSI_NULLS ON
  300. GO
  301. SET QUOTED_IDENTIFIER ON
  302. GO
  303. SET ANSI_NULLS ON
  304. GO
  305. CREATE PROCEDURE sp_CheckSRExists
  306. @SR AS varchar(20)
  307. AS
  308. BEGIN
  309. DECLARE @retval as int
  310. SET @retval = 0
  311. IF EXISTS (SELECT * FROM PssSR WHERE SR = @SR)
  312. BEGIN
  313. SET @retval = 1
  314. END
  315. SELECT @retval AS SRExists
  316. END
  317. GO
  318. SET QUOTED_IDENTIFIER OFF
  319. GO
  320. SET ANSI_NULLS ON
  321. GO
  322. SET QUOTED_IDENTIFIER OFF
  323. GO
  324. SET ANSI_NULLS OFF
  325. GO
  326. CREATE PROCEDURE sp_GetBucketComments(
  327. @BucketID varchar(100)
  328. ) AS
  329. BEGIN
  330. DECLARE @BugId as int
  331. SET @BugId = 0
  332. select @BugId = BugId FROM RaidBugs
  333. WHERE BucketID = @BucketID
  334. SELECT @BugId as BugId, CommentBy, Comment
  335. FROM Comments
  336. WHERE BucketID = @BucketID
  337. END
  338. GO
  339. SET QUOTED_IDENTIFIER OFF
  340. GO
  341. SET ANSI_NULLS ON
  342. GO
  343. GRANT EXECUTE ON [dbo].[sp_UpdateCount] TO [OcaDebug]
  344. GRANT EXECUTE ON [dbo].[sp_GetIntBucket] TO [OcaDebug]
  345. GRANT EXECUTE ON [dbo].[sp_AddCrashInstance2] TO [OcaDebug]
  346. GRANT EXECUTE ON [dbo].[sp_CheckCrashExists] TO [OcaDebug]
  347. GRANT EXECUTE ON [dbo].[sp_LinkCrashSR] TO [OcaDebug]
  348. GRANT EXECUTE ON [dbo].[sp_CheckSRExists] TO [OcaDebug]
  349. GRANT EXECUTE ON [dbo].[sp_RetriveSRBuckets] TO [OcaDebug]
  350. GRANT EXECUTE ON [dbo].[sp_GetBucketComments] TO [OcaDebug]