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.

2613 lines
114 KiB

  1. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__DriverMap__iBuck__787EE5A0]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
  2. ALTER TABLE [dbo].[DriverMap] DROP CONSTRAINT FK__DriverMap__iBuck__787EE5A0
  3. GO
  4. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__DriverMap__BinId__778AC167]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
  5. ALTER TABLE [dbo].[DriverMap] DROP CONSTRAINT FK__DriverMap__BinId__778AC167
  6. GO
  7. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetBucketCrashData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  8. drop procedure [dbo].[DBGP_GetBucketCrashData]
  9. GO
  10. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetBucketData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  11. drop procedure [dbo].[DBGP_GetBucketData]
  12. GO
  13. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetBucketStatus]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  14. drop procedure [dbo].[DBGP_GetBucketStatus]
  15. GO
  16. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetBucketsByAlias]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  17. drop procedure [dbo].[DBGP_GetBucketsByAlias]
  18. GO
  19. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetBucketsBySpecificBuildNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  20. drop procedure [dbo].[DBGP_GetBucketsBySpecificBuildNumber]
  21. GO
  22. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetCommentsByBucketID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  23. drop procedure [dbo].[DBGP_GetCommentsByBucketID]
  24. GO
  25. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetCustomerInfoByBucketID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  26. drop procedure [dbo].[DBGP_GetCustomerInfoByBucketID]
  27. GO
  28. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetCustomerInfoByIncident]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  29. drop procedure [dbo].[DBGP_GetCustomerInfoByIncident]
  30. GO
  31. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetFollowUpAliases]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  32. drop procedure [dbo].[DBGP_GetFollowUpAliases]
  33. GO
  34. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetSolvedBucketsBySpecificBuildNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  35. drop procedure [dbo].[DBGP_GetSolvedBucketsBySpecificBuildNumber]
  36. GO
  37. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_GetUnsolvedBucketsBySpecificBuildNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  38. drop procedure [dbo].[DBGP_GetUnsolvedBucketsBySpecificBuildNumber]
  39. GO
  40. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_SetBucketBugNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  41. drop procedure [dbo].[DBGP_SetBucketBugNumber]
  42. GO
  43. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGP_SetComment]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  44. drop procedure [dbo].[DBGP_SetComment]
  45. GO
  46. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_CountTotalBuckets]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  47. drop procedure [dbo].[SEP_CountTotalBuckets]
  48. GO
  49. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetBucketList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  50. drop procedure [dbo].[SEP_GetBucketList]
  51. GO
  52. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetBucketListRange]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  53. drop procedure [dbo].[SEP_GetBucketListRange]
  54. GO
  55. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddBucketFollowup]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  56. drop procedure [dbo].[sp_AddBucketFollowup]
  57. GO
  58. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddCrashInstance]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  59. drop procedure [dbo].[sp_AddCrashInstance]
  60. GO
  61. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddCrashInstance2]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  62. drop procedure [dbo].[sp_AddCrashInstance2]
  63. GO
  64. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddCrashInstance_temp]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  65. drop procedure [dbo].[sp_AddCrashInstance_temp]
  66. GO
  67. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddDriver]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  68. drop procedure [dbo].[sp_AddDriver]
  69. GO
  70. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_AddToDrBin]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  71. drop procedure [dbo].[sp_AddToDrBin]
  72. GO
  73. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CategorizeBuckets]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  74. drop procedure [dbo].[sp_CategorizeBuckets]
  75. GO
  76. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CheckCrashExists]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  77. drop procedure [dbo].[sp_CheckCrashExists]
  78. GO
  79. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_DeleteSolution]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  80. drop procedure [dbo].[sp_DeleteSolution]
  81. GO
  82. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_EmptyBuckets]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  83. drop procedure [dbo].[sp_EmptyBuckets]
  84. GO
  85. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_GetIntBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  86. drop procedure [dbo].[sp_GetIntBucket]
  87. GO
  88. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_GetProblems]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  89. drop procedure [dbo].[sp_GetProblems]
  90. GO
  91. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_HexToInt]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  92. drop procedure [dbo].[sp_HexToInt]
  93. GO
  94. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_ListBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  95. drop procedure [dbo].[sp_ListBucket]
  96. GO
  97. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_LookupBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  98. drop procedure [dbo].[sp_LookupBucket]
  99. GO
  100. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_NewIssues]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  101. drop procedure [dbo].[sp_NewIssues]
  102. GO
  103. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_NewIssuesThisWeek]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  104. drop procedure [dbo].[sp_NewIssuesThisWeek]
  105. GO
  106. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_NewIssuesToday]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  107. drop procedure [dbo].[sp_NewIssuesToday]
  108. GO
  109. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_PrivateCleanupCrash]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  110. drop procedure [dbo].[sp_PrivateCleanupCrash]
  111. GO
  112. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_ResolveBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  113. drop procedure [dbo].[sp_ResolveBucket]
  114. GO
  115. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_RetriageCrash]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  116. drop procedure [dbo].[sp_RetriageCrash]
  117. GO
  118. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_SearchDb]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  119. drop procedure [dbo].[sp_SearchDb]
  120. GO
  121. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_SendMailForBucket]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  122. drop procedure [dbo].[sp_SendMailForBucket]
  123. GO
  124. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_SolvedIssuesThisWeek]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  125. drop procedure [dbo].[sp_SolvedIssuesThisWeek]
  126. GO
  127. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_SolvedIssuesToday]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  128. drop procedure [dbo].[sp_SolvedIssuesToday]
  129. GO
  130. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BucketGroups]') and OBJECTPROPERTY(id, N'IsView') = 1)
  131. drop view [dbo].[BucketGroups]
  132. GO
  133. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FollowupInstances]') and OBJECTPROPERTY(id, N'IsView') = 1)
  134. drop view [dbo].[FollowupInstances]
  135. GO
  136. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Totals]') and OBJECTPROPERTY(id, N'IsView') = 1)
  137. drop view [dbo].[Totals]
  138. GO
  139. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[viewFollowUpBuckets]') and OBJECTPROPERTY(id, N'IsView') = 1)
  140. drop view [dbo].[viewFollowUpBuckets]
  141. GO
  142. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BucketToCrash]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  143. drop table [dbo].[BucketToCrash]
  144. GO
  145. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BucketToInt]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  146. drop table [dbo].[BucketToInt]
  147. GO
  148. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CommentMap]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  149. drop table [dbo].[CommentMap]
  150. GO
  151. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Comments]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  152. drop table [dbo].[Comments]
  153. GO
  154. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CrashInstances]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  155. drop table [dbo].[CrashInstances]
  156. GO
  157. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DrBins]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  158. drop table [dbo].[DrBins]
  159. GO
  160. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DrNames]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  161. drop table [dbo].[DrNames]
  162. GO
  163. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DriverMap]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  164. drop table [dbo].[DriverMap]
  165. GO
  166. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DriverUsed]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  167. drop table [dbo].[DriverUsed]
  168. GO
  169. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FollowupIds]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  170. drop table [dbo].[FollowupIds]
  171. GO
  172. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Followups]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  173. drop table [dbo].[Followups]
  174. GO
  175. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MachineDescription]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  176. drop table [dbo].[MachineDescription]
  177. GO
  178. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[NewBuckets]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  179. drop table [dbo].[NewBuckets]
  180. GO
  181. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OverClocked]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  182. drop table [dbo].[OverClocked]
  183. GO
  184. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[RaidBugs]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  185. drop table [dbo].[RaidBugs]
  186. GO
  187. CREATE TABLE [dbo].[BucketToCrash] (
  188. [CrashId] [bigint] NULL ,
  189. [iBucket] [int] NULL ,
  190. [gBucket] [int] NOT NULL
  191. ) ON [PRIMARY]
  192. GO
  193. CREATE TABLE [dbo].[BucketToInt] (
  194. [BucketId] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  195. [iBucket] [int] IDENTITY (100, 1) NOT NULL ,
  196. [iFollowup] [int] NULL
  197. ) ON [PRIMARY]
  198. GO
  199. CREATE TABLE [dbo].[CommentMap] (
  200. [CommentId] [int] NULL ,
  201. [iBucket] [int] NULL
  202. ) ON [PRIMARY]
  203. GO
  204. CREATE TABLE [dbo].[Comments] (
  205. [EntryDate] [datetime] NULL ,
  206. [CommentBy] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  207. [Action] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  208. [Comment] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  209. [CommentId] [int] IDENTITY (1, 1) NOT NULL ,
  210. [iBucket] [int] NULL
  211. ) ON [PRIMARY]
  212. GO
  213. CREATE TABLE [dbo].[CrashInstances] (
  214. [CrashId] [bigint] NOT NULL ,
  215. [Path] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  216. [BuildNo] [int] NOT NULL ,
  217. [Source] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  218. [CpuId] [bigint] NOT NULL ,
  219. [EntryDate] [datetime] NOT NULL ,
  220. [IncidentId] [bigint] NULL
  221. ) ON [PRIMARY]
  222. GO
  223. CREATE TABLE [dbo].[DrBins] (
  224. [CID] [bigint] NULL ,
  225. [BinID] [bigint] NULL ,
  226. [BinStamp] [int] NULL
  227. ) ON [PRIMARY]
  228. GO
  229. CREATE TABLE [dbo].[DrNames] (
  230. [BinID] [bigint] IDENTITY (1, 1) NOT NULL ,
  231. [BinName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
  232. ) ON [PRIMARY]
  233. GO
  234. CREATE TABLE [dbo].[DriverMap] (
  235. [iBucket] [int] NOT NULL ,
  236. [BinId] [bigint] NULL
  237. ) ON [PRIMARY]
  238. GO
  239. CREATE TABLE [dbo].[DriverUsed] (
  240. [CID] [bigint] NULL ,
  241. [CIDNAME] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
  242. ) ON [PRIMARY]
  243. GO
  244. CREATE TABLE [dbo].[FollowupIds] (
  245. [Followup] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  246. [iFollowup] [int] IDENTITY (1, 1) NOT NULL
  247. ) ON [PRIMARY]
  248. GO
  249. CREATE TABLE [dbo].[Followups] (
  250. [iBucket] [int] NULL ,
  251. [Followup] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
  252. ) ON [PRIMARY]
  253. GO
  254. CREATE TABLE [dbo].[MachineDescription] (
  255. [CpuId] [bigint] NOT NULL ,
  256. [Chipset] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
  257. ) ON [PRIMARY]
  258. GO
  259. CREATE TABLE [dbo].[NewBuckets] (
  260. [BucketId] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  261. [Followup] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  262. [Instances] [int] NULL
  263. ) ON [PRIMARY]
  264. GO
  265. CREATE TABLE [dbo].[OverClocked] (
  266. [CrashId] [bigint] NOT NULL
  267. ) ON [PRIMARY]
  268. GO
  269. CREATE TABLE [dbo].[RaidBugs] (
  270. [iBucket] [int] NULL ,
  271. [BugId] [int] NULL
  272. ) ON [PRIMARY]
  273. GO
  274. SET QUOTED_IDENTIFIER ON
  275. GO
  276. SET ANSI_NULLS ON
  277. GO
  278. -- View bucketGroups
  279. CREATE VIEW BucketGroups AS
  280. SELECT BucketId,
  281. Followup,
  282. Instances,
  283. BugId
  284. FROM (
  285. SELECT BucketId,
  286. Followup,
  287. RaidBugs.BugId,
  288. b.iBucket
  289. FROM BucketToInt b
  290. INNER JOIN FollowupIds F
  291. ON F.iFollowup = b.iFollowup
  292. LEFT OUTER JOIN RaidBugs
  293. ON RaidBugs.iBucket = b.iBucket
  294. ) bkt
  295. INNER JOIN (SELECT COUNT (DISTINCT CrashId) As Instances,
  296. iBucket
  297. FROM BucketToCrash
  298. GROUP BY iBucket) ci
  299. ON bkt.iBucket = ci.iBucket
  300. GO
  301. SET QUOTED_IDENTIFIER OFF
  302. GO
  303. SET ANSI_NULLS ON
  304. GO
  305. SET QUOTED_IDENTIFIER ON
  306. GO
  307. SET ANSI_NULLS ON
  308. GO
  309. -- VIEW FollowupInstances
  310. CREATE VIEW FollowupInstances AS
  311. SELECT Followup,
  312. COUNT (DISTINCT BucketId) AS Buckets,
  313. SUM (Instances) AS Instances
  314. FROM BucketGroups F
  315. GROUP BY Followup
  316. GO
  317. SET QUOTED_IDENTIFIER OFF
  318. GO
  319. SET ANSI_NULLS ON
  320. GO
  321. SET QUOTED_IDENTIFIER ON
  322. GO
  323. SET ANSI_NULLS ON
  324. GO
  325. CREATE VIEW Totals
  326. AS
  327. select SUM(Buckets) As TotalBuckets, SUM(Instances) As TotalInstances
  328. from FollowupInstances
  329. GO
  330. SET QUOTED_IDENTIFIER OFF
  331. GO
  332. SET ANSI_NULLS ON
  333. GO
  334. SET QUOTED_IDENTIFIER ON
  335. GO
  336. SET ANSI_NULLS ON
  337. GO
  338. CREATE VIEW dbo.viewFollowUpBuckets
  339. WITH SCHEMABINDING
  340. AS
  341. SELECT dbo.FollowupIds.Followup, COUNT(DISTINCT dbo.BucketToInt.iBucket) AS Buckets, COUNT(DISTINCT dbo.BucketToCrash.CrashId) AS Instances
  342. FROM dbo.BucketToCrash INNER JOIN
  343. dbo.BucketToInt ON dbo.BucketToCrash.iBucket = dbo.BucketToInt.iBucket INNER JOIN
  344. dbo.FollowupIds ON dbo.BucketToInt.iFollowup = dbo.FollowupIds.iFollowup
  345. GROUP BY dbo.FollowupIds.Followup
  346. GO
  347. SET QUOTED_IDENTIFIER OFF
  348. GO
  349. SET ANSI_NULLS ON
  350. GO
  351. SET QUOTED_IDENTIFIER OFF
  352. GO
  353. SET ANSI_NULLS OFF
  354. GO
  355. CREATE PROCEDURE DBGP_GetBucketCrashData (
  356. @bucketID int
  357. ) AS
  358. SELECT top 10 path, BuildNo, EntryDate, IncidentID FROM BUCKETTOCRASH
  359. left join CrashInstances as c on c.CrashID=BucketToCrash.CrashID
  360. where iBucket=@BucketID
  361. order by EntryDate DESC
  362. GO
  363. SET QUOTED_IDENTIFIER OFF
  364. GO
  365. SET ANSI_NULLS ON
  366. GO
  367. SET QUOTED_IDENTIFIER OFF
  368. GO
  369. SET ANSI_NULLS OFF
  370. GO
  371. CREATE PROCEDURE DBGP_GetBucketData(
  372. @BucketID int
  373. ) AS
  374. DECLARE @BucketText nvarchar(256)
  375. DECLARE @FollowUp nvarchar(50)
  376. DECLARE @Crashes int
  377. DECLARE @SolutionID int
  378. DECLARE @iFollowup int
  379. DECLARE @BugID int
  380. SELECT @BucketText = BucketID, @iFollowup = iFollowup FROM BucketToInt where iBucket = @BucketID
  381. SELECT @FollowUP = FollowUP from FollowUPIds where iFollowup = @iFollowup
  382. SELECT @Crashes = Count(*) from buckettoCrash where iBucket=@BucketID
  383. SELECT @SolutionID = SolutionID from solutions.dbo.SolvedBuckets where Bucket = @BucketID
  384. SELECT @BugID = BugID from RaidBugs where iBucket = @BucketID
  385. SELECT @BucketText as [Bucket Text], @FollowUp as [Follow Up], @Crashes as Crashes, @SolutionID as [Solution ID], @BugID as BugID
  386. GO
  387. SET QUOTED_IDENTIFIER OFF
  388. GO
  389. SET ANSI_NULLS ON
  390. GO
  391. SET QUOTED_IDENTIFIER OFF
  392. GO
  393. SET ANSI_NULLS OFF
  394. GO
  395. CREATE PROCEDURE DBGP_GetBucketStatus (
  396. @BucketID int
  397. ) AS
  398. select top 1 Action from Comments WHERE iBucket = @BucketID order by EntryDate DESC
  399. GO
  400. SET QUOTED_IDENTIFIER OFF
  401. GO
  402. SET ANSI_NULLS ON
  403. GO
  404. SET QUOTED_IDENTIFIER OFF
  405. GO
  406. SET ANSI_NULLS OFF
  407. GO
  408. CREATE PROCEDURE DBGP_GetBucketsByAlias(
  409. @Alias nvarchar(50),
  410. @QueryType tinyint = 1
  411. ) AS
  412. IF ( @QueryType = 1 )
  413. BEGIN
  414. SELECT TOP 10 [Bucket ID], [Bucket Name], @Alias as FollowUp,count([Bucket ID]) as [Crash Count], BugID, SolutionID, 1 as Operation from
  415. ( select BucketToInt.iBucket as [Bucket ID], BucketID as [Bucket Name] from followupIds
  416. left join buckettoInt on FollowUpIds.iFollowup = BucketToInt.iFollowup
  417. where followup = @Alias ) as Goodies
  418. join BucketToCrash on [Bucket ID] = BucketToCrash.iBucket
  419. left join Raidbugs on [Bucket ID] = RaidBugs.iBucket
  420. left join Solutions.dbo.SolvedBuckets on [Bucket ID] = Bucket
  421. where BugID is null and SolutionID is null
  422. group by [Bucket ID], [Bucket Name], BugID, SolutionID
  423. order by [Crash Count] DESC
  424. END
  425. IF( @QueryType = 2 )
  426. BEGIN
  427. SELECT TOP 10 [Bucket ID], [Bucket Name], @Alias as FollowUp, count([Bucket ID]) as [Crash Count], BugID, 1 as Operation from
  428. ( select BucketToInt.iBucket as [Bucket ID], BucketID as [Bucket Name] from followupIds
  429. left join buckettoInt on FollowUpIds.iFollowup = BucketToInt.iFollowup
  430. where followup = @Alias ) as Goodies
  431. join BucketToCrash on [Bucket ID] = BucketToCrash.iBucket
  432. left join Raidbugs on [Bucket ID] = RaidBugs.iBucket
  433. where BugID is not null
  434. group by [Bucket ID], [Bucket Name], BugID
  435. order by [Crash Count] DESC
  436. END
  437. IF( @QueryType = 3 )
  438. BEGIN
  439. SELECT TOP 10 [Bucket ID], [Bucket Name], @Alias as FollowUp, count([Bucket ID]) as [Crash Count], BugID, SolutionID, 1 as Operation from
  440. ( select BucketToInt.iBucket as [Bucket ID], BucketID as [Bucket Name] from followupIds
  441. left join buckettoInt on FollowUpIds.iFollowup = BucketToInt.iFollowup
  442. where followup = @Alias ) as Goodies
  443. join BucketToCrash on [Bucket ID] = BucketToCrash.iBucket
  444. left join Raidbugs on [Bucket ID] = RaidBugs.iBucket
  445. left join Solutions.dbo.SolvedBuckets on [Bucket ID] = Bucket
  446. where BugID is not null and SolutionID is not null
  447. group by [Bucket ID], [Bucket Name], BugID, SolutionID
  448. order by [Crash Count] DESC
  449. END
  450. GO
  451. SET QUOTED_IDENTIFIER OFF
  452. GO
  453. SET ANSI_NULLS ON
  454. GO
  455. SET QUOTED_IDENTIFIER OFF
  456. GO
  457. SET ANSI_NULLS OFF
  458. GO
  459. CREATE PROCEDURE DBGP_GetBucketsBySpecificBuildNumber(
  460. @Build int,
  461. @QueryType tinyint = 1
  462. ) AS
  463. --Unsolved buckets
  464. IF ( @QueryType = 1 )
  465. BEGIN
  466. SELECT top 20 two.iBucket, BucketID, FollowUp, CrashCount, BugID, SolutionID FROM (
  467. SELECT
  468. Distinct(iBucket) as iBucket, count(iBucket) as CrashCount
  469. FROM
  470. BucketToCrash
  471. INNER JOIN (
  472. SELECT crashID from CrashInstances where BuildNo = @Build
  473. ) as nCrashID
  474. ON
  475. BucketToCrash.CrashID = nCrashID.CrashID
  476. WHERE
  477. iBucket <> 101 and iBucket<>102
  478. group by iBucket
  479. ) as two
  480. INNER JOIN
  481. BucketToInt on two.iBucket = BucketToInt.iBucket
  482. LEFT JOIN
  483. Solutions.dbo.SolvedBuckets on two.iBucket=bucket
  484. LEFT JOIN
  485. FollowUpids on BucketToInt.iFollowup = followUpids.iFollowup
  486. LEFT JOIN
  487. RaidBugs on two.iBucket = RaidBugs.iBucket
  488. WHERE SolutionID is null and BugID is null
  489. order by CrashCount DESC
  490. END
  491. --Raided buckets
  492. IF( @QueryType = 2 )
  493. BEGIN
  494. SELECT top 10 two.iBucket, BucketID, FollowUp, CrashCount, BugID, SolutionID FROM (
  495. SELECT
  496. Distinct(iBucket) as iBucket, count(iBucket) as CrashCount
  497. FROM
  498. BucketToCrash
  499. INNER JOIN (
  500. SELECT crashID from CrashInstances where BuildNo = @Build
  501. ) as nCrashID
  502. ON
  503. BucketToCrash.CrashID = nCrashID.CrashID
  504. WHERE
  505. iBucket <> 101 and iBucket<>102
  506. group by iBucket
  507. ) as two
  508. INNER JOIN
  509. BucketToInt on two.iBucket = BucketToInt.iBucket
  510. LEFT JOIN
  511. Solutions.dbo.SolvedBuckets on two.iBucket=bucket
  512. LEFT JOIN
  513. FollowUpIds on BucketToInt.iFollowup = followUpIds.iFollowup
  514. LEFT JOIN
  515. RaidBugs on two.iBucket = RaidBugs.iBucket
  516. WHERE SolutionID is null and BugID is not null
  517. order by CrashCount DESC
  518. END
  519. --Solved Buckets
  520. IF( @QueryType = 3 )
  521. BEGIN
  522. SELECT top 10 two.iBucket, BucketID, FollowUp, CrashCount, BugID, SolutionID FROM (
  523. SELECT
  524. Distinct(iBucket) as iBucket, count(iBucket) as CrashCount
  525. FROM
  526. BucketToCrash
  527. INNER JOIN (
  528. SELECT crashID from CrashInstances where BuildNo = @Build
  529. ) as nCrashID
  530. ON
  531. BucketToCrash.CrashID = nCrashID.CrashID
  532. WHERE
  533. iBucket <> 101 and iBucket<>102
  534. group by iBucket
  535. ) as two
  536. INNER JOIN
  537. BucketToInt on two.iBucket = BucketToInt.iBucket
  538. LEFT JOIN
  539. Solutions.dbo.SolvedBuckets on two.iBucket=bucket
  540. LEFT JOIN
  541. FollowUpIds on BucketToInt.iFollowup = followUpIds.iFollowup
  542. LEFT JOIN
  543. RaidBugs on two.iBucket = RaidBugs.iBucket
  544. WHERE SolutionID is not null and BugID is not null
  545. order by CrashCount DESC
  546. END
  547. GO
  548. SET QUOTED_IDENTIFIER OFF
  549. GO
  550. SET ANSI_NULLS ON
  551. GO
  552. SET QUOTED_IDENTIFIER OFF
  553. GO
  554. SET ANSI_NULLS OFF
  555. GO
  556. CREATE PROCEDURE DBGP_GetCommentsByBucketID(
  557. @BucketID int
  558. ) AS
  559. SELECT EntryDate, CommentBy, [Action], Comment FROM Comments where iBucket = @BucketID ORDER BY EntryDate ASC
  560. GO
  561. SET QUOTED_IDENTIFIER OFF
  562. GO
  563. SET ANSI_NULLS ON
  564. GO
  565. SET QUOTED_IDENTIFIER ON
  566. GO
  567. SET ANSI_NULLS OFF
  568. GO
  569. CREATE PROCEDURE DBGP_GetCustomerInfoByBucketID (
  570. @BucketID int
  571. ) AS
  572. --Select top 10 Crash.Path, Inc.IncidentID, Created, Display, ComputerName, [Description], Repro, Comments, Email, Contact, Phone, Lang from
  573. -- KaCustomer2.dbo.Incident as Inc
  574. --inner join KaCustomer2.dbo.customer as Cust on Inc.HighId = Cust.HighID and Inc.LowId = Cust.LowID
  575. --inner join CrashDB.dbo.CrashInstances as crash on crash.IncidentID = Inc.IncidentID
  576. -- where sBucket=@BucketID order by [Description] desc
  577. --GO
  578. Select top 10 Crash.Path, BuildNo, EntryDate, Inc.IncidentID from
  579. KaCustomer2.dbo.Incident as Inc
  580. inner join KaCustomer2.dbo.customer as Cust on Inc.HighId = Cust.HighID and Inc.LowId = Cust.LowID
  581. inner join CrashDB.dbo.CrashInstances as crash on crash.IncidentID = Inc.IncidentID
  582. where sBucket=@BucketID order by [Description] desc
  583. GO
  584. SET QUOTED_IDENTIFIER OFF
  585. GO
  586. SET ANSI_NULLS ON
  587. GO
  588. SET QUOTED_IDENTIFIER OFF
  589. GO
  590. SET ANSI_NULLS OFF
  591. GO
  592. CREATE PROCEDURE DBGP_GetCustomerInfoByIncident(
  593. @IncidentID int
  594. ) AS
  595. --SELECT * FROM KaCustomer2.dbo.Incident where IncidentID = @IncidentID
  596. --select Display, ComputerName, OSName, OSVersion, OSLang, Description, Repro, Comments from KaCustomer2.dbo.Incident where IncidentID = @IncidentID
  597. select Email, Contact,Phone, Lang, Created, Display, ComputerName, OSName, OSVersion, OSLang, Description, Repro, Comments from
  598. KaCustomer2.dbo.Incident as I
  599. LEFT JOIN KaCustomer2.dbo.Customer as C on I.HighID=C.HighID and I.LowID=C.LowID
  600. where IncidentID = @IncidentID
  601. GO
  602. SET QUOTED_IDENTIFIER OFF
  603. GO
  604. SET ANSI_NULLS ON
  605. GO
  606. SET QUOTED_IDENTIFIER OFF
  607. GO
  608. SET ANSI_NULLS OFF
  609. GO
  610. CREATE PROCEDURE DBGP_GetFollowUpAliases AS
  611. select distinct(FollowUP), FollowUp from FollowUPIds order by FollowUP ASC
  612. GO
  613. SET QUOTED_IDENTIFIER OFF
  614. GO
  615. SET ANSI_NULLS ON
  616. GO
  617. SET QUOTED_IDENTIFIER OFF
  618. GO
  619. SET ANSI_NULLS OFF
  620. GO
  621. CREATE PROCEDURE DBGP_GetSolvedBucketsBySpecificBuildNumber (
  622. @Build int
  623. ) AS
  624. SELECT top 10 two.iBucket, BucketID, FollowUp, CrashCount FROM (
  625. SELECT
  626. Distinct(iBucket) as iBucket, count(iBucket) as CrashCount
  627. FROM
  628. BucketToCrash
  629. INNER JOIN (
  630. SELECT crashID from CrashInstances where BuildNo = @Build
  631. ) as nCrashID
  632. ON
  633. BucketToCrash.CrashID = nCrashID.CrashID
  634. WHERE
  635. iBucket <> 101 and iBucket<>102
  636. group by iBucket
  637. ) as two
  638. INNER JOIN
  639. BucketToInt on two.iBucket = BucketToInt.iBucket
  640. LEFT JOIN
  641. Solutions.dbo.SolvedBuckets on two.iBucket=bucket
  642. LEFT JOIN
  643. FollowUpIds on BucketToInt.iFollowup = followUpIds.iFollowup
  644. WHERE SolutionID is NOT null
  645. order by CrashCount DESC
  646. GO
  647. SET QUOTED_IDENTIFIER OFF
  648. GO
  649. SET ANSI_NULLS ON
  650. GO
  651. SET QUOTED_IDENTIFIER OFF
  652. GO
  653. SET ANSI_NULLS OFF
  654. GO
  655. CREATE PROCEDURE DBGP_GetUnsolvedBucketsBySpecificBuildNumber (
  656. @Build int
  657. ) AS
  658. SELECT top 10 two.iBucket, BucketID, FollowUp, CrashCount FROM (
  659. SELECT
  660. Distinct(iBucket) as iBucket, count(iBucket) as CrashCount
  661. FROM
  662. BucketToCrash
  663. INNER JOIN (
  664. SELECT crashID from CrashInstances where BuildNo = @Build
  665. ) as nCrashID
  666. ON
  667. BucketToCrash.CrashID = nCrashID.CrashID
  668. WHERE
  669. iBucket <> 101 and iBucket<>102
  670. group by iBucket
  671. ) as two
  672. INNER JOIN
  673. BucketToInt on two.iBucket = BucketToInt.iBucket
  674. LEFT JOIN
  675. Solutions.dbo.SolvedBuckets on two.iBucket=bucket
  676. LEFT JOIN
  677. FollowUpids on BucketToInt.iFollowup = followUpids.iFollowup
  678. WHERE SolutionID is null
  679. order by CrashCount DESC
  680. GO
  681. SET QUOTED_IDENTIFIER OFF
  682. GO
  683. SET ANSI_NULLS ON
  684. GO
  685. SET QUOTED_IDENTIFIER OFF
  686. GO
  687. SET ANSI_NULLS OFF
  688. GO
  689. CREATE PROCEDURE DBGP_SetBucketBugNumber (
  690. @BucketID int,
  691. @BugID int
  692. ) AS
  693. IF EXISTS( SELECT iBucket FROM RaidBugs WHERE iBucket=@BucketID )
  694. UPDATE RaidBugs SET BugID=@BugID WHERE iBucket=@BucketID
  695. ELSE
  696. INSERT INTO RaidBugs (iBucket, BugID ) VALUES ( @BucketID, @BugID )
  697. GO
  698. SET QUOTED_IDENTIFIER OFF
  699. GO
  700. SET ANSI_NULLS ON
  701. GO
  702. SET QUOTED_IDENTIFIER OFF
  703. GO
  704. SET ANSI_NULLS OFF
  705. GO
  706. CREATE PROCEDURE DBGP_SetComment(
  707. @By varchar(20),
  708. @Action nvarchar(50),
  709. @Comment nvarchar(1000),
  710. @iBucket int
  711. ) AS
  712. INSERT INTO Comments ( EntryDate, CommentBy, Action, Comment, iBucket ) VALUES ( GETDATE(), @By, @Action, @Comment, @iBucket)
  713. GO
  714. SET QUOTED_IDENTIFIER OFF
  715. GO
  716. SET ANSI_NULLS ON
  717. GO
  718. SET QUOTED_IDENTIFIER OFF
  719. GO
  720. SET ANSI_NULLS OFF
  721. GO
  722. CREATE PROCEDURE SEP_CountTotalBuckets AS
  723. SELECT COUNT(*) as TotalBuckets FROM BucketToInt
  724. GO
  725. SET QUOTED_IDENTIFIER OFF
  726. GO
  727. SET ANSI_NULLS ON
  728. GO
  729. SET QUOTED_IDENTIFIER OFF
  730. GO
  731. SET ANSI_NULLS OFF
  732. GO
  733. CREATE PROCEDURE SEP_GetBucketList AS
  734. SELECT iBucket, BucketId FROM BucketToInt
  735. GO
  736. SET QUOTED_IDENTIFIER OFF
  737. GO
  738. SET ANSI_NULLS ON
  739. GO
  740. SET QUOTED_IDENTIFIER OFF
  741. GO
  742. SET ANSI_NULLS OFF
  743. GO
  744. CREATE PROCEDURE SEP_GetBucketListRange(
  745. @Start as int,
  746. @Size as int
  747. ) AS
  748. SELECT iBucket, BucketId FROM BucketToInt where iBucket >= @Start and iBucket <= (@Start + @Size) order by iBucket
  749. GO
  750. SET QUOTED_IDENTIFIER OFF
  751. GO
  752. SET ANSI_NULLS ON
  753. GO
  754. SET QUOTED_IDENTIFIER ON
  755. GO
  756. SET ANSI_NULLS ON
  757. GO
  758. -- Update StoreProc to add buckets
  759. CREATE PROCEDURE sp_AddBucketFollowup
  760. @i_BucketStr varchar(100),
  761. @i_FollowupStr varchar(50)
  762. AS
  763. BEGIN
  764. DECLARE @iBucket int
  765. DECLARE @iFollowup int
  766. IF NOT EXISTS (SELECT * FROM FollowupIds WHERE Followup = @i_FollowupStr)
  767. BEGIN
  768. INSERT INTO FollowupIds VALUES (@i_FollowupStr)
  769. SELECT @iFollowup = @@IDENTITY
  770. END
  771. ELSE
  772. BEGIN
  773. SELECT @iFollowup = iFollowup FROM FollowupIds WHERE Followup = @i_FollowupStr
  774. END
  775. SELECT @iBucket = iBucket FROM BucketToInt WHERE BucketId = @i_BucketStr
  776. IF NOT ( @iBucket IS NULL)
  777. BEGIN
  778. -- Bucket exists in bucket table
  779. IF NOT EXISTS (SELECT iBucket FROM BucketToInt b
  780. WHERE BucketId = @i_BucketStr AND b.iFollowup = @iFollowup)
  781. BEGIN
  782. -- Update followup
  783. UPDATE BucketToInt
  784. SET iFollowup = @iFollowup
  785. WHERE iBucket = @iBucket
  786. END
  787. END
  788. ELSE
  789. BEGIN
  790. INSERT INTO BucketToInt (BucketId, iFollowup)
  791. VALUES (@i_BucketStr, @iFollowup)
  792. SELECT @iBucket = @@IDENTITY
  793. END
  794. -- SELECT @i_BucketStr AS BucketId, @iBucket AS iBucket, @iFollowup AS iFollowup
  795. -- select * from buckettoint where bucketid = @i_BucketStr
  796. END
  797. GO
  798. SET QUOTED_IDENTIFIER OFF
  799. GO
  800. SET ANSI_NULLS ON
  801. GO
  802. SET QUOTED_IDENTIFIER ON
  803. GO
  804. SET ANSI_NULLS ON
  805. GO
  806. CREATE PROCEDURE sp_AddCrashInstance (
  807. @ip_CrashId bigint,
  808. @ip_BucketId varchar(100),
  809. @ip_Path varchar(256),
  810. @ip_FollowUp varchar(50),
  811. @ip_BuildNo int,
  812. @ip_Source varchar(100),
  813. @ip_CpuId bigint,
  814. @ip_OverClocked bit,
  815. @ip_IncidentId bigint,
  816. @ip_gBucketId varchar(100),
  817. @ip_DriverName varchar (100)
  818. )
  819. AS
  820. BEGIN
  821. DECLARE @RetVal int
  822. DECLARE @b_BucketExists int
  823. DECLARE @b_CrashExists bit
  824. DECLARE @i_siBucket int
  825. DECLARE @i_giBucket int
  826. DECLARE @b_AddCrashMap int
  827. SET NOCOUNT ON
  828. SET @RetVal = 0
  829. -- Add specific bucket
  830. EXEC sp_AddBucketFollowup @ip_BucketId, @ip_FollowUp
  831. SELECT @i_siBucket = iBucket FROM BucketToInt
  832. WHERE BucketId = @ip_BucketId
  833. -- Add generic bucket
  834. SELECT @i_giBucket = iBucket FROM BucketToInt WHERE BucketId = @ip_gBucketId
  835. IF (@i_giBucket IS NULL)
  836. BEGIN
  837. INSERT BucketToInt VALUES (@ip_gBucketId,0)
  838. SELECT @i_giBucket = @@IDENTITY
  839. END
  840. -- Insert the CPU info into MachineDescription table
  841. IF NOT EXISTS
  842. (SELECT CpuId FROM MachineDescription WHERE CpuId = @ip_CpuId)
  843. BEGIN
  844. INSERT MachineDescription VALUES (@ip_CpuId, 'default')
  845. END
  846. -- Add the Crash Instance
  847. SET @b_CrashExists = 1
  848. IF NOT EXISTS
  849. (SELECT CrashID FROM CrashInstances WHERE CrashId = @ip_CrashId)
  850. BEGIN
  851. SET @b_CrashExists = 0
  852. IF @ip_IncidentId = 0
  853. BEGIN
  854. SET @ip_IncidentId = crashdb.dbo.fn_HexToInt( SUBSTRING ( @ip_Path ,42, 5), 5)
  855. END
  856. INSERT INTO CrashInstances
  857. VALUES ( @ip_CrashId,
  858. @ip_Path,
  859. @ip_BuildNo,
  860. @ip_Source,
  861. @ip_CpuId,
  862. GETDATE(),
  863. @ip_IncidentId)
  864. END
  865. -- Insert the Bucket into bucketmapping table
  866. SET @b_AddCrashMap = 1
  867. IF @b_CrashExists = 1
  868. BEGIN
  869. IF EXISTS ( SELECT CrashID FROM BucketToCrash
  870. WHERE CrashId = @ip_CrashId AND iBucket != @i_siBucket
  871. AND iBucket != @i_giBucket)
  872. BEGIN
  873. SET @b_AddCrashMap = 0
  874. DELETE FROM BucketToCrash WHERE CrashId = @ip_CrashId
  875. END
  876. END
  877. ELSE
  878. BEGIN
  879. SET @b_AddCrashMap = 0
  880. END
  881. IF (@b_AddCrashMap = 0)
  882. BEGIN
  883. -- specific bucket mapping
  884. INSERT BucketToCrash VALUES (@ip_CrashId, @i_siBucket)
  885. -- generic bucket mapping
  886. INSERT BucketToCrash VALUES (@ip_CrashId, @i_giBucket)
  887. END
  888. -- Add Overclocked info
  889. IF @ip_OverClocked = 1
  890. BEGIN
  891. INSERT OverClocked VALUES (@ip_CrashId)
  892. END
  893. IF (@b_CrashExists = 0)
  894. BEGIN
  895. SET @RetVal = @RetVal + 1
  896. END
  897. -- Add Driver Name
  898. IF (@ip_DriverName <> '')
  899. BEGIN
  900. EXEC sp_AddDriver @ip_DriverName, @i_siBucket
  901. END
  902. SET NOCOUNT OFF
  903. RETURN @retval
  904. END
  905. GO
  906. SET QUOTED_IDENTIFIER OFF
  907. GO
  908. SET ANSI_NULLS ON
  909. GO
  910. SET QUOTED_IDENTIFIER OFF
  911. GO
  912. SET ANSI_NULLS ON
  913. GO
  914. /*
  915. Adds a crash instance to CrashDb
  916. Returns isBucket, igBucket if successfull
  917. */
  918. CREATE PROCEDURE sp_AddCrashInstance2 (
  919. @ip_CrashId bigint,
  920. @ip_BucketId varchar(100),
  921. @ip_Path varchar(256),
  922. @ip_FollowUp varchar(50),
  923. @ip_BuildNo int,
  924. @ip_Source varchar(100),
  925. @ip_CpuId bigint,
  926. @ip_OverClocked bit,
  927. @ip_IncidentId bigint,
  928. @ip_gBucketId varchar(100),
  929. @ip_DriverName varchar (100)
  930. )
  931. AS
  932. BEGIN
  933. DECLARE @RetVal int
  934. DECLARE @b_BucketExists int
  935. DECLARE @b_CrashExists bit
  936. DECLARE @i_siBucket int
  937. DECLARE @i_giBucket int
  938. DECLARE @b_AddCrashMap int
  939. SET NOCOUNT ON
  940. SET @RetVal = 0
  941. -- Add specific bucket
  942. EXEC sp_AddBucketFollowup @ip_BucketId, @ip_FollowUp
  943. SELECT @i_siBucket = iBucket FROM BucketToInt
  944. WHERE BucketId = @ip_BucketId
  945. -- Add generic bucket
  946. SELECT @i_giBucket = iBucket FROM BucketToInt WHERE BucketId = @ip_gBucketId
  947. IF (@i_giBucket IS NULL)
  948. BEGIN
  949. INSERT BucketToInt VALUES (@ip_gBucketId,0)
  950. SELECT @i_giBucket = @@IDENTITY
  951. END
  952. -- Insert the CPU info into MachineDescription table
  953. IF NOT EXISTS
  954. (SELECT CpuId FROM MachineDescription WHERE CpuId = @ip_CpuId)
  955. BEGIN
  956. INSERT MachineDescription VALUES (@ip_CpuId, 'default')
  957. END
  958. -- Add the Crash Instance
  959. SET @b_CrashExists = 1
  960. IF NOT EXISTS
  961. (SELECT CrashID FROM CrashInstances WHERE CrashId = @ip_CrashId)
  962. BEGIN
  963. SET @b_CrashExists = 0
  964. IF @ip_IncidentId = 0
  965. BEGIN
  966. SET @ip_IncidentId = crashdb.dbo.fn_HexToInt( SUBSTRING ( @ip_Path ,42, 5), 5)
  967. END
  968. INSERT INTO CrashInstances
  969. VALUES ( @ip_CrashId,
  970. @ip_Path,
  971. @ip_BuildNo,
  972. @ip_Source,
  973. @ip_CpuId,
  974. GETDATE(),
  975. @ip_IncidentId)
  976. END
  977. -- Insert the Bucket into bucketmapping table
  978. SET @b_AddCrashMap = 1
  979. IF @b_CrashExists = 1
  980. BEGIN
  981. IF EXISTS ( SELECT CrashID FROM BucketToCrash
  982. WHERE CrashId = @ip_CrashId)
  983. BEGIN
  984. SET @b_AddCrashMap = 0
  985. UPDATE BucketToCrash
  986. SET iBucket = @i_siBucket, gBucket = @i_giBucket
  987. FROM BucketToCrash
  988. WHERE CrashId = @ip_CrashId
  989. END
  990. END
  991. ELSE
  992. BEGIN
  993. -- specific and generic bucket mapping
  994. INSERT BucketToCrash VALUES (@ip_CrashId, @i_siBucket, @i_giBucket)
  995. END
  996. -- Add Overclocked info
  997. IF (@ip_OverClocked = 1)
  998. BEGIN
  999. IF NOT EXISTS (SELECT CrashId FROM OverClocked WHERE CrashId = @ip_CrashId)
  1000. BEGIN
  1001. INSERT OverClocked VALUES (@ip_CrashId)
  1002. END
  1003. END
  1004. -- Add Driver Name
  1005. IF (@ip_DriverName <> '')
  1006. BEGIN
  1007. EXEC sp_AddDriver @ip_DriverName, @i_siBucket
  1008. END
  1009. SET NOCOUNT OFF
  1010. SELECT @i_siBucket AS sBucket, @i_giBucket AS gBucket
  1011. -- RETURN @retval
  1012. END
  1013. GO
  1014. SET QUOTED_IDENTIFIER OFF
  1015. GO
  1016. SET ANSI_NULLS ON
  1017. GO
  1018. SET QUOTED_IDENTIFIER OFF
  1019. GO
  1020. SET ANSI_NULLS ON
  1021. GO
  1022. CREATE PROCEDURE sp_AddCrashInstance_temp (
  1023. @ip_CrashId bigint,
  1024. @ip_BucketId varchar(100),
  1025. @ip_Path varchar(256),
  1026. @ip_FollowUp varchar(50),
  1027. @ip_BuildNo int,
  1028. @ip_Source varchar(100),
  1029. @ip_CpuId bigint,
  1030. @ip_OverClocked bit,
  1031. @ip_IncidentId bigint,
  1032. @ip_gBucketId varchar(100),
  1033. @ip_DriverName varchar (100)
  1034. )
  1035. AS
  1036. BEGIN
  1037. DECLARE @RetVal int
  1038. DECLARE @b_BucketExists int
  1039. DECLARE @b_CrashExists bit
  1040. DECLARE @i_siBucket int
  1041. DECLARE @i_giBucket int
  1042. DECLARE @b_AddCrashMap int
  1043. SET NOCOUNT ON
  1044. SET @RetVal = 0
  1045. -- Add specific bucket
  1046. EXEC sp_AddBucketFollowup @ip_BucketId, @ip_FollowUp
  1047. SELECT @i_siBucket = iBucket FROM BucketToInt
  1048. WHERE BucketId = @ip_BucketId
  1049. -- Add generic bucket
  1050. IF NOT EXISTS
  1051. (SELECT iBucket FROM BucketToInt WHERE BucketId = @ip_gBucketId)
  1052. BEGIN
  1053. INSERT BucketToInt VALUES (@ip_gBucketId,0)
  1054. END
  1055. SELECT @i_giBucket = @@IDENTITY
  1056. -- Insert the CPU info into MachineDescription table
  1057. IF NOT EXISTS
  1058. (SELECT CpuId FROM MachineDescription WHERE CpuId = @ip_CpuId)
  1059. BEGIN
  1060. INSERT MachineDescription VALUES (@ip_CpuId, 'default')
  1061. END
  1062. -- Add the Crash Instance
  1063. SET @b_CrashExists = 1
  1064. IF NOT EXISTS
  1065. (SELECT CrashID FROM CrashInstances WHERE CrashId = @ip_CrashId)
  1066. BEGIN
  1067. SET @b_CrashExists = 0
  1068. IF @ip_IncidentId = 0
  1069. BEGIN
  1070. SET @ip_IncidentId = crashdb.dbo.fn_HexToInt( SUBSTRING ( @ip_Path ,42, 5), 5)
  1071. END
  1072. INSERT INTO CrashInstances
  1073. VALUES ( @ip_CrashId,
  1074. @ip_Path,
  1075. @ip_BuildNo,
  1076. @ip_Source,
  1077. @ip_CpuId,
  1078. GETDATE(),
  1079. @ip_IncidentId)
  1080. END
  1081. -- Insert the Bucket into bucketmapping table
  1082. SET @b_AddCrashMap = 1
  1083. IF @b_CrashExists = 1
  1084. BEGIN
  1085. IF EXISTS ( SELECT CrashID FROM BucketToCrash
  1086. WHERE CrashId = @ip_CrashId AND iBucket != @i_siBucket
  1087. AND iBucket != @i_giBucket)
  1088. BEGIN
  1089. SET @b_AddCrashMap = 0
  1090. DELETE FROM BucketToCrash WHERE CrashId = @ip_CrashId
  1091. END
  1092. END
  1093. ELSE
  1094. BEGIN
  1095. SET @b_AddCrashMap = 0
  1096. END
  1097. IF (@b_AddCrashMap = 0)
  1098. BEGIN
  1099. -- specific bucket mapping
  1100. INSERT BucketToCrash VALUES (@ip_CrashId, @i_siBucket)
  1101. -- generic bucket mapping
  1102. INSERT BucketToCrash VALUES (@ip_CrashId, @i_giBucket)
  1103. END
  1104. -- Add Overclocked info
  1105. IF @ip_OverClocked = 1
  1106. BEGIN
  1107. INSERT OverClocked VALUES (@ip_CrashId)
  1108. END
  1109. IF (@b_CrashExists = 0)
  1110. BEGIN
  1111. SET @RetVal = @RetVal + 1
  1112. END
  1113. -- Add Driver Name
  1114. IF (@ip_DriverName <> '')
  1115. BEGIN
  1116. EXEC sp_AddDriver @ip_DriverName, @i_siBucket
  1117. END
  1118. SET NOCOUNT OFF
  1119. RETURN @retval
  1120. END
  1121. GO
  1122. SET QUOTED_IDENTIFIER OFF
  1123. GO
  1124. SET ANSI_NULLS ON
  1125. GO
  1126. SET QUOTED_IDENTIFIER ON
  1127. GO
  1128. SET ANSI_NULLS ON
  1129. GO
  1130. CREATE PROCEDURE sp_AddDriver (
  1131. @i_DriverName varchar(100),
  1132. @i_Bucket int
  1133. )
  1134. AS
  1135. BEGIN
  1136. DECLARE @BinId int
  1137. IF NOT EXISTS (SELECT * FROM DrNames WHERE BinName = @i_DriverName)
  1138. BEGIN
  1139. INSERT INTO DrNames VALUES (@i_DriverName)
  1140. END
  1141. SELECT @BinId = BinId FROM DrNames WHERE BinName = @i_DriverName
  1142. IF NOT EXISTS (SELECT * FROM DriverMap WHERE iBucket = @i_Bucket)
  1143. BEGIN
  1144. INSERT INTO DriverMap VALUES ( @i_Bucket, @BinId )
  1145. END
  1146. ELSE
  1147. BEGIN
  1148. UPDATE DriverMap
  1149. SET BinId = @BinId
  1150. WHERE iBucket = @i_Bucket
  1151. END
  1152. END
  1153. GO
  1154. SET QUOTED_IDENTIFIER OFF
  1155. GO
  1156. SET ANSI_NULLS ON
  1157. GO
  1158. SET QUOTED_IDENTIFIER ON
  1159. GO
  1160. SET ANSI_NULLS ON
  1161. GO
  1162. /****** Object: Stored Procedure dbo.sp_AddToDrBin Script Date: 11/7/2001 3:53:58 AM ******/
  1163. CREATE PROC sp_AddToDrBin (
  1164. @i_CIDNAME VARCHAR(20),
  1165. @i_BinName VARCHAR(100),
  1166. @i_BinStamp INT
  1167. ) AS
  1168. BEGIN
  1169. DECLARE @t_CID BIGINT
  1170. DECLARE @t_CIDName VARCHAR(20)
  1171. DECLARE @t_BinID BIGINT
  1172. DECLARE @t_BinName VARCHAR(100)
  1173. -- Insert record into table DriversUsed
  1174. IF NOT EXISTS
  1175. (SELECT CIDName FROM DriverUsed WHERE CIDName = @i_CIDName)
  1176. BEGIN
  1177. INSERT dbo.DriverUsed(CIDName) VALUES (@i_CIDName)
  1178. END
  1179. -- Insert record into table DrNames
  1180. IF NOT EXISTS
  1181. (SELECT BinName FROM dbo.DrNames WHERE BinName = LOWER(@i_BinName))
  1182. BEGIN
  1183. INSERT dbo.DrNames(BinName) VALUES (LOWER(@i_BinName))
  1184. END
  1185. --
  1186. SELECT @t_BinID=BinID FROM dbo.DrNames WHERE BinName = LOWER(@i_BinName)
  1187. SELECT @t_CID=CID FROM dbo.DriverUsed WHERE CIDName = @i_CIDName
  1188. -- Insert record into
  1189. IF NOT EXISTS
  1190. (SELECT CID FROM dbo.DrBins WHERE CID = @t_CID AND BinID = @t_BinID AND BinStamp = @i_BinStamp)
  1191. BEGIN
  1192. INSERT dbo.DrBins VALUES(@t_CID, @i_BinStamp, @t_BinID)
  1193. END
  1194. END
  1195. GO
  1196. SET QUOTED_IDENTIFIER OFF
  1197. GO
  1198. SET ANSI_NULLS ON
  1199. GO
  1200. SET QUOTED_IDENTIFIER ON
  1201. GO
  1202. SET ANSI_NULLS ON
  1203. GO
  1204. /****** Object: Stored Procedure dbo.sp_CategorizeBuckets Script Date: 11/7/2001 3:53:58 AM ******/
  1205. CREATE PROCEDURE sp_CategorizeBuckets
  1206. @ip_Followup varchar(50),
  1207. @ip_SortBy varchar(100)
  1208. AS
  1209. BEGIN
  1210. -- sort by bucketid
  1211. IF (@ip_SortBy = 'BucketId' OR @ip_SortBy = 'Bucket')
  1212. BEGIN
  1213. select BucketId,
  1214. Instances,
  1215. BugId AS Bug
  1216. from BucketGroups
  1217. WHERE Followup = @ip_Followup
  1218. order by BucketId
  1219. END
  1220. -- sort by #Instances
  1221. IF (@ip_SortBy = 'Instances')
  1222. BEGIN
  1223. select BucketId,
  1224. Instances,
  1225. BugId AS Bug
  1226. from BucketGroups
  1227. WHERE Followup = @ip_Followup
  1228. order by Instances DESC
  1229. END
  1230. END
  1231. GO
  1232. SET QUOTED_IDENTIFIER OFF
  1233. GO
  1234. SET ANSI_NULLS ON
  1235. GO
  1236. SET QUOTED_IDENTIFIER ON
  1237. GO
  1238. SET ANSI_NULLS ON
  1239. GO
  1240. CREATE PROCEDURE sp_CheckCrashExists
  1241. @i_CrashId AS bigint
  1242. AS
  1243. BEGIN
  1244. DECLARE @retval as int
  1245. SET @retval = 0
  1246. IF EXISTS (SELECT * FROM CrashInstances WHERE CrashId = @i_CrashId)
  1247. BEGIN
  1248. SET @retval = 1
  1249. END
  1250. SELECT @retval
  1251. END
  1252. GO
  1253. SET QUOTED_IDENTIFIER OFF
  1254. GO
  1255. SET ANSI_NULLS ON
  1256. GO
  1257. SET QUOTED_IDENTIFIER ON
  1258. GO
  1259. SET ANSI_NULLS ON
  1260. GO
  1261. /****** Object: Stored Procedure dbo.sp_DeleteSolution Script Date: 11/7/2001 3:53:58 AM ******/
  1262. CREATE PROCEDURE sp_DeleteSolution
  1263. @BucketId varchar(100)
  1264. AS
  1265. BEGIN
  1266. DECLARE @iBucket AS int
  1267. DECLARE @DelId AS int
  1268. SELECT @iBucket = iBucket FROM BucketToInt
  1269. WHERE BucketId = @BucketId
  1270. DELETE FROM RaidBugs
  1271. WHERE iBucket = @iBucket
  1272. SELECT @DelId = SolId FROM SolutionsMap
  1273. WHERE iBucket = @iBucket
  1274. DELETE FROM SolutionsMap
  1275. WHERE iBucket = @iBucket
  1276. IF NOT EXISTS (SELECT * FROM Solutions WHERE SolId = @DelId)
  1277. BEGIN
  1278. -- No one else used the same solution
  1279. DELETE FROM Solutions
  1280. WHERE @DelId = Solutions.SolId
  1281. END
  1282. SELECT @DelId = CommentId FROM CommentMap
  1283. WHERE iBucket = @iBucket
  1284. DELETE FROM CommentMap
  1285. WHERE iBucket = @iBucket
  1286. IF NOT EXISTS (SELECT * FROM Comments WHERE CommentId = @DelId)
  1287. BEGIN
  1288. -- No one else used the same solution
  1289. DELETE FROM Coments
  1290. WHERE @DelId = Comments.CommentId
  1291. END
  1292. END
  1293. GO
  1294. SET QUOTED_IDENTIFIER OFF
  1295. GO
  1296. SET ANSI_NULLS ON
  1297. GO
  1298. SET QUOTED_IDENTIFIER ON
  1299. GO
  1300. SET ANSI_NULLS ON
  1301. GO
  1302. /****** Object: Stored Procedure dbo.sp_EmptyBuckets Script Date: 11/7/2001 3:53:58 AM ******/
  1303. CREATE PROCEDURE sp_EmptyBuckets
  1304. @i_Remove int
  1305. AS
  1306. BEGIN
  1307. IF @i_Remove = 1
  1308. BEGIN
  1309. DELETE FROM CrashBuckets
  1310. WHERE BucketId NOT IN (SELECT DISTINCT(BucketId) FROM BucketMap)
  1311. END
  1312. SELECT Followup,
  1313. BucketId AS Bucket
  1314. FROM CrashBuckets
  1315. WHERE BucketId NOT IN (SELECT DISTINCT(BucketId) FROM BucketMap)
  1316. END
  1317. GO
  1318. SET QUOTED_IDENTIFIER OFF
  1319. GO
  1320. SET ANSI_NULLS ON
  1321. GO
  1322. SET QUOTED_IDENTIFIER ON
  1323. GO
  1324. SET ANSI_NULLS ON
  1325. GO
  1326. CREATE PROCEDURE sp_GetIntBucket
  1327. @i_BucketId1 as varchar(256),
  1328. @i_BucketId2 as varchar(256)
  1329. AS
  1330. BEGIN
  1331. DECLARE @id1 as int
  1332. DECLARE @id2 as int
  1333. SELECT @id1 = iBucket FROM BucketToInt
  1334. WHERE BucketId = @i_BucketId1
  1335. SELECT @id2 = iBucket FROM BucketToInt
  1336. WHERE BucketId = @i_BucketId2
  1337. SELECT @id1, @id2
  1338. END
  1339. GO
  1340. SET QUOTED_IDENTIFIER OFF
  1341. GO
  1342. SET ANSI_NULLS ON
  1343. GO
  1344. SET QUOTED_IDENTIFIER ON
  1345. GO
  1346. SET ANSI_NULLS ON
  1347. GO
  1348. /****** Object: Stored Procedure dbo.sp_GetProblems Script Date: 11/7/2001 3:53:58 AM ******/
  1349. CREATE PROCEDURE sp_GetProblems
  1350. @ip_BucketTypes int
  1351. AS
  1352. BEGIN
  1353. -- BucketType = 0 : List all
  1354. IF (@ip_BucketTypes = 0)
  1355. BEGIN
  1356. select * from bucketgroups
  1357. order by Instances DESC
  1358. END
  1359. -- BucketType = 1 : List unresolved, unraided
  1360. IF (@ip_BucketTypes = 1)
  1361. BEGIN
  1362. select * from bucketgroups
  1363. --where ISNULL(bugid, 0) = 0 AND ISNULL(solvedate, '1/1/1900') = '1/1/1900'
  1364. order by Instances DESC
  1365. END
  1366. -- BucketType = 2 : List raided buckets
  1367. IF (@ip_BucketTypes = 2)
  1368. BEGIN
  1369. select * from bucketgroups
  1370. where ISNULL(bugid, 0)<>0
  1371. order by Instances DESC
  1372. END
  1373. -- BucketType = 3 : List solved buckets
  1374. IF (@ip_BucketTypes = 3)
  1375. BEGIN
  1376. select * from bucketgroups
  1377. -- where ISNULL(solvedate, '1/1/1900')<>'1/1/1900'
  1378. order by Instances DESC
  1379. END
  1380. END
  1381. GO
  1382. SET QUOTED_IDENTIFIER OFF
  1383. GO
  1384. SET ANSI_NULLS ON
  1385. GO
  1386. SET QUOTED_IDENTIFIER ON
  1387. GO
  1388. SET ANSI_NULLS ON
  1389. GO
  1390. /****** Object: Stored Procedure dbo.sp_HexToInt Script Date: 11/7/2001 3:53:58 AM ******/
  1391. CREATE PROCEDURE sp_HexToInt
  1392. @i_HexVal as varchar(10),
  1393. @i_Len as int
  1394. AS
  1395. BEGIN
  1396. DECLARE @Value as bigint
  1397. DECLARE @Sub as int
  1398. SET @Sub = 0
  1399. SET @Value = 0
  1400. while (@i_Len <> @Sub)
  1401. BEGIN
  1402. SET @Value = @Value * 16
  1403. SET @Value = @Value + (ASCII(SUBSTRING(@i_HexVal, @Sub+1, 1)) - 48)
  1404. SET @Sub = @Sub + 1
  1405. END
  1406. return @Value
  1407. END
  1408. GO
  1409. SET QUOTED_IDENTIFIER OFF
  1410. GO
  1411. SET ANSI_NULLS ON
  1412. GO
  1413. SET QUOTED_IDENTIFIER ON
  1414. GO
  1415. SET ANSI_NULLS ON
  1416. GO
  1417. /****** Object: Stored Procedure dbo.sp_ListBucket Script Date: 11/7/2001 3:53:58 AM ******/
  1418. CREATE PROCEDURE sp_ListBucket
  1419. @BucketId varchar (100)
  1420. AS
  1421. BEGIN
  1422. SELECT BuildNo, Path, Source FROM CrashInsTances, BucketToInt, BucketToCrash
  1423. WHERE CrashInstances.CrashId = BucketToCrash.CrashId AND
  1424. BucketToInt.iBucket = BucketToCrash.iBucket AND
  1425. BucketToInt.BucketId=@BucketId
  1426. END
  1427. GO
  1428. SET QUOTED_IDENTIFIER OFF
  1429. GO
  1430. SET ANSI_NULLS ON
  1431. GO
  1432. SET QUOTED_IDENTIFIER ON
  1433. GO
  1434. SET ANSI_NULLS ON
  1435. GO
  1436. /****** Object: Stored Procedure dbo.sp_LookupBucket Script Date: 11/7/2001 3:53:58 AM ******/
  1437. CREATE PROCEDURE sp_LookupBucket
  1438. @s_BucketId varchar(100)
  1439. AS
  1440. BEGIN
  1441. DECLARE @i_Bug int
  1442. DECLARE @d_CommentDate DATETIME
  1443. DECLARE @s_Comment varchar (1000)
  1444. DECLARE @s_OSVersion varchar (30)
  1445. DECLARE @s_CommentBy varchar (30)
  1446. DECLARE @iBucket AS int
  1447. DECLARE @FaultyDriver AS varchar (100)
  1448. SELECT @iBucket = iBucket FROM BucketToInt
  1449. WHERE BucketId = @s_BucketId
  1450. -- Get the Raid bug
  1451. SELECT @i_Bug = BugId FROM RaidBugs
  1452. WHERE iBucket = @iBucket
  1453. -- get the comment
  1454. SELECT @s_Comment = Comment, @s_CommentBy = CommentBy, @d_CommentDate = EntryDate
  1455. FROM Comments, CommentMap
  1456. WHERE Comments.iBucket = @iBucket AND Comments.CommentId = CommentMap.CommentId
  1457. -- get faulty driver
  1458. SELECT @FaultyDriver = BinName FROM DrNames, DriverMap
  1459. WHERE DriverMap.iBucket = @iBucket AND DriverMap.BinID = DrNames.BinID
  1460. -- Output values
  1461. SELECT @i_Bug AS Bug,
  1462. @s_Comment AS Comment,
  1463. @s_CommentBy AS CommentBy,
  1464. @d_CommentDate AS CommentDate,
  1465. @FaultyDriver AS FaultyDriver
  1466. END
  1467. GO
  1468. SET QUOTED_IDENTIFIER OFF
  1469. GO
  1470. SET ANSI_NULLS ON
  1471. GO
  1472. SET QUOTED_IDENTIFIER ON
  1473. GO
  1474. SET ANSI_NULLS ON
  1475. GO
  1476. /****** Object: Stored Procedure dbo.sp_NewIssues Script Date: 11/7/2001 3:53:58 AM ******/
  1477. CREATE PROCEDURE sp_NewIssues
  1478. @i_DaysOld int
  1479. AS
  1480. BEGIN
  1481. IF @i_DaysOld = 0
  1482. BEGIN
  1483. SET @i_DaysOld = 1
  1484. END
  1485. -- Display new buckets
  1486. SELECT BucketToInt.BucketId AS Bucket,
  1487. MAX(EntryDate)AS NewestEntry
  1488. FROM CrashInstances, BucketToInt, BucketToCrash
  1489. WHERE DATEDIFF(day,EntryDate,GETDATE()) < @i_DaysOld AND
  1490. BucketToCrash.CrashId = CrashInstances.CrashId AND
  1491. BucketToCrash.iBucket = BucketToInt.iBucket
  1492. GROUP BY BucketId
  1493. END
  1494. GO
  1495. SET QUOTED_IDENTIFIER OFF
  1496. GO
  1497. SET ANSI_NULLS ON
  1498. GO
  1499. SET QUOTED_IDENTIFIER ON
  1500. GO
  1501. SET ANSI_NULLS ON
  1502. GO
  1503. /****** Object: Stored Procedure dbo.sp_NewIssuesThisWeek Script Date: 11/7/2001 3:53:59 AM ******/
  1504. CREATE PROCEDURE sp_NewIssuesThisWeek
  1505. AS
  1506. BEGIN
  1507. -- Display new crashes added today
  1508. /* SELECT BucketMap.BucketId AS Bucket,
  1509. MIN(EntryDate)AS OldestEntry
  1510. FROM CrashInstances, BucketMap
  1511. WHERE DATEDIFF(day,EntryDate,GETDATE()) <= 7 AND BucketMap.CrashId = CrashInstances.CrashId
  1512. GROUP BY BucketId
  1513. */
  1514. EXEC sp_NewIssues 7
  1515. END
  1516. GO
  1517. SET QUOTED_IDENTIFIER OFF
  1518. GO
  1519. SET ANSI_NULLS ON
  1520. GO
  1521. SET QUOTED_IDENTIFIER ON
  1522. GO
  1523. SET ANSI_NULLS ON
  1524. GO
  1525. /****** Object: Stored Procedure dbo.sp_NewIssuesToday Script Date: 11/7/2001 3:53:59 AM ******/
  1526. CREATE PROCEDURE sp_NewIssuesToday
  1527. AS
  1528. BEGIN
  1529. -- Display new crashes added today
  1530. /* SELECT Followup,
  1531. BucketMap.BucketId AS Bucket,
  1532. COUNT (BucketMap.CrashId) AS Instances
  1533. FROM CrashInstances, BucketMap, CrashBuckets
  1534. WHERE DATEPART(dd,EntryDate) = DATEPART(dd,GETDATE()) AND
  1535. DATEPART(mm,EntryDate) = DATEPART(mm,GETDATE()) AND
  1536. DATEPART(yy,EntryDate) = DATEPART(yy,GETDATE()) AND
  1537. BucketMap.CrashId = CrashInstances.CrashId AND
  1538. CrashBuckets.BucketId = BucketMap.BucketId
  1539. GROUP BY BucketMap.BucketId, Followup
  1540. ORDER BY Instances DESC
  1541. */
  1542. EXEC sp_NewIssues 1
  1543. END
  1544. GO
  1545. SET QUOTED_IDENTIFIER OFF
  1546. GO
  1547. SET ANSI_NULLS ON
  1548. GO
  1549. SET QUOTED_IDENTIFIER OFF
  1550. GO
  1551. SET ANSI_NULLS ON
  1552. GO
  1553. CREATE PROCEDURE sp_PrivateCleanupCrash
  1554. @CrashId bigint
  1555. AS
  1556. BEGIN
  1557. DELETE FROM BucketToCrash where Crashid = @CrashId
  1558. IF EXISTS (SELECT * FROM OVERCLOCKED WHERE CrashId = @CrashId)
  1559. BEGIN
  1560. DELETE FROM OverClocked WHERE CrashId = @CrashId
  1561. END
  1562. delete from Crashinstances where Crashid = @CrashId
  1563. END
  1564. GO
  1565. SET QUOTED_IDENTIFIER OFF
  1566. GO
  1567. SET ANSI_NULLS ON
  1568. GO
  1569. SET QUOTED_IDENTIFIER ON
  1570. GO
  1571. SET ANSI_NULLS ON
  1572. GO
  1573. /****** Object: Stored Procedure dbo.sp_ResolveBucket Script Date: 11/7/2001 3:53:58 AM ******/
  1574. CREATE PROCEDURE sp_ResolveBucket
  1575. @BucketId varchar(100),
  1576. @BugId int ,
  1577. @SolvedBy varchar(20),
  1578. @Comment varchar (1000)
  1579. AS
  1580. BEGIN
  1581. DECLARE @iBucket AS int
  1582. DECLARE @TodaysDate AS DATETIME
  1583. DECLARE @OSVersion varchar (30)
  1584. DECLARE @Description varchar (50)
  1585. SET @Description = ''
  1586. SET @OSVersion = ''
  1587. SET @TodaysDate = GETDATE()
  1588. SELECT @iBucket = iBucket FROM BucketToInt
  1589. WHERE BucketId = @BucketId
  1590. -- BugId != 0 or description not null
  1591. -- Insert it into RaidBugs
  1592. IF (@BugId <> 0 OR @Description <> '')
  1593. BEGIN
  1594. DELETE FROM RaidBugs
  1595. WHERE iBucket = @iBucket
  1596. INSERT INTO RaidBugs
  1597. VALUES (@iBucket, @BugId)
  1598. END
  1599. -- Insert it into SolvedIssues
  1600. IF (@Description <> '')
  1601. BEGIN
  1602. DECLARE @SolId AS INT
  1603. SELECT @SolId = SolId FROM SolutionsMap WHERE iBucket = @iBucket
  1604. DELETE FROM SolutionsMap
  1605. WHERE iBucket = @iBucket
  1606. IF @SolId <> NULL
  1607. BEGIN
  1608. DELETE FROM Solutions WHERE SolId = @SolId
  1609. END
  1610. INSERT INTO Solutions
  1611. VALUES (@TodaysDate, @Description,@SolvedBy, 0, @OSVersion)
  1612. SELECT @SolId = SolId FROM Solutions WHERE SolveDate = @TodaysDate AND SolvedBy = @SolvedBy
  1613. INSERT INTO SolutionsMap
  1614. VALUES ( @SolId, @iBucket)
  1615. END
  1616. -- Add the comment
  1617. IF (@Comment <> '')
  1618. BEGIN
  1619. DECLARE @CommentId AS INT
  1620. SELECT @CommentId = CommentId FROM CommentMap WHERE iBucket = @iBucket
  1621. DELETE FROM CommentMap
  1622. WHERE iBucket = @iBucket
  1623. IF @CommentId <> NULL
  1624. BEGIN
  1625. DELETE FROM Comments WHERE CommentId = @CommentId
  1626. END
  1627. INSERT INTO Comments VALUES (@TodaysDate,@SolvedBy, '', @Comment, @iBucket)
  1628. SELECT @CommentId = CommentId FROM Comments WHERE EntryDate = @TodaysDate AND CommentBy = @SolvedBy
  1629. INSERT INTO CommentMap
  1630. VALUES ( @CommentId, @iBucket)
  1631. END
  1632. END
  1633. GO
  1634. SET QUOTED_IDENTIFIER OFF
  1635. GO
  1636. SET ANSI_NULLS ON
  1637. GO
  1638. SET QUOTED_IDENTIFIER ON
  1639. GO
  1640. SET ANSI_NULLS ON
  1641. GO
  1642. -- Change RetriageCrash
  1643. CREATE PROCEDURE sp_RetriageCrash
  1644. @ip_CrashId bigint,
  1645. @ip_sBucketId varchar(100),
  1646. @ip_gBucketId varchar(100),
  1647. @ip_FollowUp varchar(50)
  1648. AS
  1649. BEGIN
  1650. DECLARE @b_BucketExists int
  1651. DECLARE @isBucket int
  1652. DECLARE @igBucket int
  1653. -- Check if crash exists
  1654. IF NOT EXISTS
  1655. (SELECT CrashId FROM CrashInstances WHERE CrashId = @ip_CrashId)
  1656. BEGIN
  1657. return 1
  1658. END
  1659. -- Add Buckt to followup mapping
  1660. EXEC sp_AddBucketFollowup @ip_sBucketId, @ip_FollowUp
  1661. SELECT @isBucket = iBucket FROM BucketToInt WHERE BucketId = @ip_sBucketId
  1662. SELECT @igBucket = iBucket FROM BucketToInt WHERE BucketId = @ip_gBucketId
  1663. -- Insert the Bucket into bucketmapping table
  1664. IF EXISTS
  1665. (SELECT iBucket FROM BucketToCrash WHERE CrashId = @ip_CrashId )
  1666. BEGIN
  1667. UPDATE BucketToCrash
  1668. SET iBucket = @isBucket, gBucket = @igBucket
  1669. FROM BucketToCrash
  1670. WHERE CrashId = @ip_CrashId
  1671. END
  1672. ELSE
  1673. BEGIN
  1674. INSERT BucketToCrash VALUES (@ip_CrashId, @isBucket, @igBucket)
  1675. END
  1676. RETURN 0
  1677. END
  1678. GO
  1679. SET QUOTED_IDENTIFIER OFF
  1680. GO
  1681. SET ANSI_NULLS ON
  1682. GO
  1683. SET QUOTED_IDENTIFIER ON
  1684. GO
  1685. SET ANSI_NULLS ON
  1686. GO
  1687. /****** Object: Stored Procedure dbo.sp_SearchDb Script Date: 11/7/2001 3:53:58 AM ******/
  1688. CREATE PROCEDURE sp_SearchDb
  1689. @i_BucketStr varchar(100),
  1690. @i_BucketStrType int, -- 0 : Equals, 1 : Contains
  1691. @i_FollowUpStr varchar( 50 ),
  1692. @i_FollowUpType int, -- 0 : Equals, 1 : Contains
  1693. @i_BuildLower int,
  1694. @i_BuildUpper int,
  1695. @i_SolType int, -- 0 : All, 1 : Solved, 2 : Raided
  1696. @i_GroupBuckets int -- 0 : List individual instances, 1 groupby buckets
  1697. AS
  1698. BEGIN
  1699. SELECT * FROM BucketGroups
  1700. WHERE (@i_FollowUpStr = '' OR Followup LIKE @i_FollowUpStr) AND
  1701. (@i_BucketStr = '' OR BucketId LIKE @i_BucketStr)
  1702. END
  1703. /*
  1704. OLD CODE
  1705. IF (@i_BucketStr = '' AND @i_GroupBuckets <> 0)
  1706. BEGIN
  1707. SELECT cb.BucketId AS Bucket,
  1708. fp.Followup AS Followup,
  1709. COUNT (DISTINCT bm.CrashId) As Instances
  1710. FROM CrashInstances AS ci, BucketToCrash AS bm, FollowupIds AS fp,
  1711. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  1712. WHERE (@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  1713. (@i_SolType = 0 OR
  1714. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  1715. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  1716. ((@i_SolType = 3) AND cb.iBucket IN
  1717. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  1718. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  1719. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  1720. fp.iBucket = cb.iBucket AND
  1721. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  1722. GROUP BY cb.BucketId, fp.Followup
  1723. ORDER BY instances DESC
  1724. END
  1725. ELSE IF (@i_GroupBuckets <> 0)
  1726. BEGIN
  1727. SELECT cb.BucketId AS Bucket,
  1728. fp.Followup AS Followup,
  1729. COUNT (DISTINCT bm.CrashId) As Instances
  1730. FROM CrashInstances AS ci, BucketToCrash AS bm, Followups AS fp,
  1731. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  1732. WHERE (@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  1733. (@i_BucketStr = '' OR cb.BucketId LIKE @i_BucketStr) AND
  1734. (@i_SolType = 0 OR
  1735. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  1736. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  1737. ((@i_SolType = 3) AND cb.iBucket IN
  1738. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  1739. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  1740. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  1741. fp.iBucket = cb.iBucket AND
  1742. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  1743. GROUP BY cb.BucketId, fp.Followup
  1744. ORDER BY instances DESC
  1745. END
  1746. ELSE
  1747. BEGIN
  1748. SELECT DISTINCT Path, cb.BucketId AS Bucket, Source
  1749. FROM CrashInstances AS ci, BucketToCrash AS bm, Followups AS fp,
  1750. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  1751. WHERE ((@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  1752. (@i_BucketStr = '' OR cb.BucketId LIKE @i_BucketStr)) AND
  1753. ( @i_SolType = 0 OR
  1754. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  1755. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  1756. ((@i_SolType = 3) AND cb.iBucket IN
  1757. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  1758. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  1759. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  1760. fp.iBucket = cb.iBucket AND
  1761. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  1762. END
  1763. */
  1764. GO
  1765. SET QUOTED_IDENTIFIER OFF
  1766. GO
  1767. SET ANSI_NULLS ON
  1768. GO
  1769. SET QUOTED_IDENTIFIER ON
  1770. GO
  1771. SET ANSI_NULLS ON
  1772. GO
  1773. /****** Object: Stored Procedure dbo.sp_SendMailForBucket Script Date: 11/7/2001 3:53:58 AM ******/
  1774. CREATE PROCEDURE sp_SendMailForBucket
  1775. @Bucket varchar(100)
  1776. AS
  1777. BEGIN
  1778. DECLARE @MailTo varchar(50)
  1779. DECLARE @Mesg varchar(1000)
  1780. DECLARE @Subj varchar(50)
  1781. SET @MailTo = ''
  1782. SET @Subj = 'You have been assigned a new bucket'
  1783. SET @Mesg = 'Click on http://dbgdumps/cr/crashinstances.asp?bucketid=' + @Bucket
  1784. -- Send mail to person following up on given Bucket
  1785. SELECT @MailTo = Followup FROM CrashBuckets
  1786. WHERE BucketId = @Bucket
  1787. IF @MailTo <> ''
  1788. BEGIN
  1789. EXEC master.dbo.xp_startmail
  1790. EXEC master.dbo.xp_sendmail @recipients = @MailTo,
  1791. @message = @Mesg,
  1792. @subject = @Subj
  1793. EXEC master.dbo.xp_stopmail
  1794. END
  1795. ELSE
  1796. BEGIN
  1797. SELECT 'Could not send mail - bucket not found'
  1798. END
  1799. END
  1800. GO
  1801. SET QUOTED_IDENTIFIER OFF
  1802. GO
  1803. SET ANSI_NULLS ON
  1804. GO
  1805. SET QUOTED_IDENTIFIER ON
  1806. GO
  1807. SET ANSI_NULLS ON
  1808. GO
  1809. /****** Object: Stored Procedure dbo.sp_SolvedIssuesThisWeek Script Date: 11/7/2001 3:53:58 AM ******/
  1810. CREATE PROCEDURE sp_SolvedIssuesThisWeek
  1811. AS
  1812. BEGIN
  1813. -- Display crash buckets
  1814. SELECT BucketId AS Bucket,
  1815. SolveDate
  1816. FROM SolvedIssues
  1817. WHERE SolveDate >= DATEADD(day,-7,GETDATE())
  1818. END
  1819. GO
  1820. SET QUOTED_IDENTIFIER OFF
  1821. GO
  1822. SET ANSI_NULLS ON
  1823. GO
  1824. SET QUOTED_IDENTIFIER ON
  1825. GO
  1826. SET ANSI_NULLS ON
  1827. GO
  1828. /****** Object: Stored Procedure dbo.sp_SolvedIssuesToday Script Date: 11/7/2001 3:53:58 AM ******/
  1829. CREATE PROCEDURE sp_SolvedIssuesToday
  1830. AS
  1831. BEGIN
  1832. -- Display crash buckets solved today
  1833. SELECT BucketId AS Bucket,
  1834. SolveDate
  1835. FROM SolvedIssues
  1836. WHERE DATEPART(dd,SolveDate) = DATEPART(dd,GETDATE()) AND
  1837. DATEPART(mm,SolveDate) = DATEPART(mm,GETDATE()) AND
  1838. DATEPART(yy,SolveDate) = DATEPART(yy,GETDATE())
  1839. END
  1840. GO
  1841. SET QUOTED_IDENTIFIER OFF
  1842. GO
  1843. SET ANSI_NULLS ON
  1844. GO