FIX: Assertion Raised When DELETE Is Performed on a Table Joined with a View

This article was previously published under Q295039
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 351229 (SHILOH_BUGS)
SYMPTOMS
An assertion may be raised when a DELETE is performed on a table and the following conditions are true:
  • The DELETE is based on a join with a view.
  • The table has a clustered index.
  • The table is not empty (that is, has at least one record).
When the DELETE is run from Query Analyzer, the following message may be seen:
Server: Msg 3624, Level 20, State 1, Line 3

Location: recbase.cpp:1352
Expression: FALSE
SPID: 51
Process ID: 137
Description: Invalid switch value

Connection Broken
The following assertion can also be seen in the SQL Server errorlog:

Short Stack Dump77F97AC6 Module(ntdll+00017AC6) (ZwGetContextThread+0000000B)0092569E Module(sqlservr+0052569E) (utassert_fail(enum UTASSERT_TYPE,char const *,char const *,int,char const *,...)+000002E9)007FD074 Module(sqlservr+003FD074) (RecBase::MarkGhost(unsigned char *)+0000002F)0041E485 Module(sqlservr+0001E485) (Page::MarkGhostRow(int,class XdesId const &)+0000001E) 0041E7E6 Module(sqlservr+0001E7E6) (PageRef::DeleteRows(struct BUF *,int,int,enum ETabStatus,int,class XDES *,unsigned int)+000003B1) 0041E44E Module(sqlservr+0001E44E) (PageRef::MarkIndexRowAsDeleted(struct BUF *,int,class SDES *)+00000052) 0041EB8C Module(sqlservr+0001EB8C) (SDES::IndexDeleteRow(class Scan_rid &,int,int,int)+000001ED) 00442DD0 Module(sqlservr+00042DD0) (RowsetSS::DeleteRows(unsigned long,unsigned long,unsigned long const * const,unsigned long * const)+00000161) 004BFD41 Module(sqlservr+000BFD41) (CQScanUpdate::GetRow(unsigned long *,unsigned long *)+000000AB) 00427985 Module(sqlservr+00027985) (CQueryScan::GetRow(unsigned long *,unsigned long *)+00000014) 004271BA Module(sqlservr+000271BA) (CStmtQuery::ErsqExecuteQuery(class CMsqlExecContext *,class CEsComp const *,class CEsComp const *,unsigned long *,int,int)const +0000040D) 0042EA36 Module(sqlservr+0002EA36) (CStmtDML::XretExecuteNormal(class CMsqlExecContext *)const +000002F0) 0042E82D Module(sqlservr+0002E82D) (CStmtDML::XretExecute(class CMsqlExecContext *)const +0000001C) 004160DB Module(sqlservr+000160DB) (CMsqlExecContext::ExecuteStmts(class ExecutionContext *)+0000027E) 00415765 Module(sqlservr+00015765) (CMsqlExecContext::Execute(class CCompPlan *,class CParamExchange *)+000001C7) 00415410 Module(sqlservr+00015410) (CSQLSource::Execute(class CParamExchange *)+00000343) 00459A54 Module(sqlservr+00059A54) (language_exec(struct srv_proc *)+000003C8) 004175D8 Module(sqlservr+000175D8) (process_commands(struct srv_proc *)+000000E0) 410735D0 Module(UMS+000035D0) (ProcessWorkRequests(class UmsWorkQueue *)+00000264) 4107382C Module(UMS+0000382C) (ThreadStartRoutine(void *)+000000BC) 7800BEA1 Module(MSVCRT+0000BEA1) (_beginthread+000000CE) 77E92CA8 Module(KERNEL32+00012CA8) (CreateFileA+0000011B)-------------------------------------------------------------------------------2001-04-17 20:08:45.21 spid51    SQL Server Assertion: File: <recbase.cpp>, line = 1352 Failed Assertion = 'FALSE' Invalid switch value.2001-04-17 20:08:45.22 spid51    Error: 3624, Severity: 20, State: 1.				
CAUSE
This problem is due to the fact that one of the objects in the join is only a view, not a real table.
RESOLUTION
To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in theMicrosoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack
STATUS
Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.
MORE INFORMATION
You can reproduce this assertion from Query Analyzer by using the following script:
USE PUBSGO/****** Object:  Table [dbo].[state_id]    Script Date: 4/5/01 5:38:17 PM ******/ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[state_id]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[state_id]GO/****** Object:  Table [dbo].[state_id]    Script Date: 4/5/01 5:38:17 PM ******/ CREATE TABLE [dbo].[state_id] (	[sid] [int] NULL ) ON [PRIMARY]GO/* The DELETE runs fine without any asserts if the table has no clustered index. */ CREATE  CLUSTERED  INDEX [clus_id] ON [dbo].[state_id]([sid]) ON [PRIMARY]GOSET NOCOUNT ON/* The DELETE runs fine without any asserts if the table is empty. */ INSERT state_id VALUES(1)GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[state_code]') and OBJECTPROPERTY(id, N'IsView') = 1)drop view [dbo].[state_code]GOCREATE VIEW state_code(sid,name,code) AS	SELECT 0, 'Texas', 'TX' UNION	SELECT 1, 'California', 'CA' UNION	SELECT 2, 'Washington', 'WA' UNION	SELECT 3, 'Arizona', 'AZ' GOBEGIN TRANDELETE state_id FROM state_id,state_codeROLLBACK TRAN/* Cleanup code */ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[state_id]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[state_id] GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[state_code]') and OBJECTPROPERTY(id, N'IsView') = 1) drop view [dbo].[state_code] GO				
Properties

Article ID: 295039 - Last Review: 01/16/2015 22:17:33 - Revision: 3.2

  • Microsoft SQL Server 2000 Standard Edition
  • kbnosurvey kbarchive kbbug kbfix kbsqlserv2000sp1fix KB295039
Feedback