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.

103 lines
3.2 KiB

  1. SET QUOTED_IDENTIFIER ON
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. CREATE PROCEDURE sp_SearchDb
  6. @i_BucketStr varchar(100),
  7. @i_BucketStrType int, -- 0 : Equals, 1 : Contains
  8. @i_FollowUpStr varchar( 50 ),
  9. @i_FollowUpType int, -- 0 : Equals, 1 : Contains
  10. @i_BuildLower int,
  11. @i_BuildUpper int,
  12. @i_SolType int, -- 0 : All, 1 : Solved, 2 : Raided
  13. @i_GroupBuckets int -- 0 : List individual instances, 1 groupby buckets
  14. AS
  15. BEGIN
  16. IF (@i_BucketStr = '' AND @i_GroupBuckets <> 0)
  17. BEGIN
  18. SELECT cb.BucketId AS Bucket,
  19. fp.Followup AS Followup,
  20. COUNT (DISTINCT bm.CrashId) As Instances
  21. FROM CrashInstances AS ci, BucketToCrash AS bm, Followups AS fp,
  22. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  23. WHERE (@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  24. (@i_SolType = 0 OR
  25. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  26. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  27. ((@i_SolType = 3) AND cb.iBucket IN
  28. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  29. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  30. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  31. fp.iBucket = cb.iBucket AND
  32. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  33. GROUP BY cb.BucketId, fp.Followup
  34. ORDER BY instances DESC
  35. END
  36. ELSE IF (@i_GroupBuckets <> 0)
  37. BEGIN
  38. SELECT cb.BucketId AS Bucket,
  39. fp.Followup AS Followup,
  40. COUNT (DISTINCT bm.CrashId) As Instances
  41. FROM CrashInstances AS ci, BucketToCrash AS bm, Followups AS fp,
  42. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  43. WHERE (@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  44. (@i_BucketStr = '' OR cb.BucketId LIKE @i_BucketStr) AND
  45. (@i_SolType = 0 OR
  46. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  47. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  48. ((@i_SolType = 3) AND cb.iBucket IN
  49. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  50. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  51. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  52. fp.iBucket = cb.iBucket AND
  53. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  54. GROUP BY cb.BucketId, fp.Followup
  55. ORDER BY instances DESC
  56. END
  57. ELSE
  58. BEGIN
  59. SELECT DISTINCT Path, cb.BucketId AS Bucket, Source
  60. FROM CrashInstances AS ci, BucketToCrash AS bm, Followups AS fp,
  61. BucketToInt AS cb, SolutionsMap AS si, RaidBugs AS rb
  62. WHERE ((@i_FollowUpStr = '' OR fp.Followup LIKE @i_FollowUpStr) AND
  63. (@i_BucketStr = '' OR cb.BucketId LIKE @i_BucketStr)) AND
  64. ( @i_SolType = 0 OR
  65. ((@i_SolType = 1) AND cb.iBucket IN (SELECT iBucket FROM SolutionsMap)) OR
  66. ((@i_SolType = 2) AND cb.iBucket IN (SELECT iBucket FROM RaidBugs)) OR
  67. ((@i_SolType = 3) AND cb.iBucket IN
  68. (SELECT SolutionsMap.iBucket FROM SolutionsMap, RaidBugs
  69. WHERE RaidBugs.iBucket = SolutionsMap.iBucket))) AND
  70. ci.CrashId = bm.CrashId AND bm.iBucket = cb.iBucket AND
  71. fp.iBucket = cb.iBucket AND
  72. (ci.BuildNo BETWEEN @i_BuildLower AND @i_BuildUpper)
  73. END
  74. END
  75. GO
  76. SET QUOTED_IDENTIFIER OFF
  77. GO
  78. SET ANSI_NULLS ON
  79. GO