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.

142 lines
5.0 KiB

  1. /*
  2. Adds a crash instance to CrashDb
  3. Returns isBucket, igBucket if successfull
  4. */
  5. CREATE PROCEDURE sp_AddCrashInstance2 (
  6. @ip_retriageBucket bit,
  7. @ip_BucketId varchar(100),
  8. @ip_Path varchar(256),
  9. @ip_FollowUp varchar(50),
  10. @ip_BuildNo int,
  11. @ip_Source int,
  12. @ip_CpuId bigint,
  13. @ip_OverClocked bit,
  14. @ip_IncidentId bigint,
  15. @ip_gBucketId varchar(100),
  16. @ip_DriverName varchar (100),
  17. @ip_Type int
  18. )
  19. AS
  20. BEGIN
  21. DECLARE @i_sBucket int
  22. DECLARE @i_gBucket int
  23. DECLARE @i_Followup int
  24. DECLARE @i_OldFollowup int
  25. DECLARE @i_DriverName int
  26. DECLARE @i_OldDriverName int
  27. SET NOCOUNT ON
  28. -- Find the specific bucket
  29. SELECT @i_sBucket = iBucket,
  30. @i_OldFollowup = iFollowup,
  31. @i_OldDriverName = iDriverName
  32. FROM BucketToInt WHERE BucketId = @ip_BucketId
  33. -- If the specifc bucket does not exist, or we want to update the
  34. -- fields
  35. IF ( @i_sBucket IS NULL OR @ip_retriageBucket = 1)
  36. BEGIN
  37. SELECT @i_Followup = iFollowup FROM FollowupIds
  38. WHERE Followup = @ip_FollowUp
  39. --get (or add) the followup information.
  40. -- IF NOT EXISTS (SELECT * FROM FollowupIds
  41. -- WHERE Followup = @ip_FollowUp)
  42. if (@i_Followup is null)
  43. BEGIN
  44. INSERT INTO FollowupIds VALUES (@ip_FollowUp, NULL)
  45. SELECT @i_Followup = @@IDENTITY
  46. END
  47. -- ELSE
  48. -- BEGIN
  49. -- SELECT @i_Followup = iFollowup FROM FollowupIds
  50. -- WHERE Followup = @ip_FollowUp
  51. -- END
  52. --get (or add) the driver name.
  53. SELECT @i_DriverName = iDriverName FROM DrNames
  54. WHERE DriverName = @ip_DriverName
  55. if (@i_DriverName is null)
  56. -- IF NOT EXISTS (SELECT * FROM DrNames
  57. -- WHERE DriverName = @ip_DriverName)
  58. BEGIN
  59. INSERT INTO DrNames (DriverName)
  60. VALUES (@ip_DriverName)
  61. SELECT @i_DriverName = @@IDENTITY
  62. END
  63. -- ELSE
  64. -- BEGIN
  65. -- SELECT @i_DriverName = iDriverName FROM DrNames
  66. -- WHERE DriverName = @ip_DriverName
  67. -- END
  68. END
  69. IF ( @i_sBucket IS NULL)
  70. BEGIN
  71. INSERT INTO BucketToInt (BucketId, iFollowup, iDriverName, Platform) -- added platfrom param sbeer 02/20/02
  72. VALUES (@ip_BucketId, @i_Followup, @i_DriverName, @ip_Type)
  73. SELECT @i_sBucket = @@IDENTITY
  74. END
  75. ELSE
  76. BEGIN
  77. -- Bucket exists in bucket table. Update it if necessary
  78. IF @ip_RetriageBucket = 1
  79. BEGIN
  80. IF ( (@i_OldFollowup != @i_Followup) OR
  81. (@i_OldDriverName != @i_DriverName) )
  82. BEGIN
  83. UPDATE BucketToInt
  84. SET iFollowup = @i_Followup, iDriverName = @i_DriverName, Platform = @ip_Type -- added platfrom param sbeer 02/20/02
  85. WHERE iBucket = @i_sBucket
  86. END
  87. END
  88. END
  89. -- Add generic bucket
  90. SELECT @i_gBucket = iBucket FROM BucketToInt
  91. WHERE BucketId = @ip_gBucketId
  92. IF (@i_gBucket IS NULL)
  93. BEGIN
  94. INSERT BucketToInt ( BucketID, iBucket, iFollowUp,Platform) VALUES (@ip_gBucketId,0,0,@ip_Type) --added explicit column names solson 02/14/02
  95. SELECT @i_gBucket = @@IDENTITY
  96. END
  97. -- Add the Crash Instance to the crash instance table and the mapping
  98. -- table
  99. IF NOT EXISTS (SELECT IncidentId FROM CrashInstances
  100. WHERE IncidentId = @ip_IncidentId)
  101. BEGIN
  102. INSERT INTO CrashInstances
  103. VALUES ( @ip_Path,
  104. @ip_BuildNo,
  105. @ip_CpuId,
  106. @ip_IncidentId,
  107. @i_sBucket,
  108. @i_gBucket,
  109. GetDate(),
  110. @ip_Source)
  111. END
  112. ELSE
  113. BEGIN
  114. IF (@ip_retriageBucket = 1)
  115. BEGIN
  116. UPDATE CrashInstances
  117. SET sBucket = @i_sBucket, gBucket = @i_gBucket
  118. WHERE IncidentId = @ip_IncidentId
  119. END
  120. END
  121. SET NOCOUNT OFF
  122. SELECT @i_sBucket AS sBucket, @i_gBucket AS gBucket
  123. END
  124. GO