BUG: INSERT..EXEC That Attempts to Insert a Record That Violates a Foreign Key Constraint Causes AV (264189)



The information in this article applies to:

  • Microsoft SQL Server 6.5

This article was previously published under Q264189
BUG #: 18985 (SQLBUG_65)

SYMPTOMS

When you run an INSERT..EXECUTE statement that attempts to insert a record that violates a foreign key constraint, a handled access violation (AV) may be generated.

WORKAROUND

Use an INSERT..SELECT statement instead.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 6.5.

MORE INFORMATION

To reproduce this problem, execute the following statements:
use pubs
go

create table test(col1 char(4))
go
insert test values ('1234')
go

create procedure fk_violate
as
begin
    select col1 from test
end
go

create procedure test_violate
as
begin
        insert pub_info (pub_id)
        exec fk_violate
end
				
Executing the following statement twice in the same session in ISQL/w generates the access violation. The first execution gives the foreign key violation message, and the second execution produces the AV.
exec test_violate
				
The following is the first 15 lines of the stack trace from retail SQL Server build 6.50.416:
2000/01/25 19:14:57.15 spid12   EXCEPTION_ACCESS_VIOLATION raised, attempting to create symptom dump
2000/01/25 19:14:57.17 spid12   Initializing symptom dump and stack dump facilities
2000/01/25 19:15:07.95 spid12   ***BEGIN STACK TRACE***
2000/01/25 19:15:08.56 spid12   0x004F44F5 in sqlservr.exe, exec_eop_28486_len_22e_759420er () + 0x0105
2000/01/25 19:15:08.98 spid12   0x0047E410 in sqlservr.exe, exec_eop_52926_len_22e_759420er () + 0xE6E0
2000/01/25 19:15:09.23 spid12   0x0047DAEF in sqlservr.exe, run_101302s_2934en_22e_759420er () + 0xDDBF
2000/01/25 19:15:09.53 spid12   0x00411863 in sqlservr.exe, exec_eop () + 0x0343
2000/01/25 19:15:09.62 spid12   0x0047DBC3 in sqlservr.exe, run_101302s_2934en_22e_759420er () + 0xDE93
2000/01/25 19:15:09.76 spid12   0x004118A8 in sqlservr.exe, exec_eop () + 0x0388
2000/01/25 19:15:09.76 spid12   0x00411BA7 in sqlservr.exe, execute () + 0x0687
2000/01/25 19:15:09.81 spid12   0x0040BF6A in sqlservr.exe, s_execute_1147c_73e_190420820er () + 0x044A
2000/01/25 19:15:09.89 spid12   0x0040D6E9 in sqlservr.exe, sequencer () + 0x0049
2000/01/25 19:15:10.03 spid12   0x00417F13 in sqlservr.exe, execproc () + 0x0233
2000/01/25 19:15:10.18 spid12   0x0040C201 in sqlservr.exe, s_execute_1147c_73e_190420820er () + 0x0121
2000/01/25 19:15:10.18 spid12   0x0040D6E9 in sqlservr.exe, sequencer () + 0x0049
2000/01/25 19:15:10.23 spid12   0x00417F13 in sqlservr.exe, execproc () + 0x0233
2000/01/25 19:15:10.34 spid12   0x0040C201 in sqlservr.exe, s_execute_1147c_73e_190420820er () + 0x0121
2000/01/25 19:15:10.34 spid12   0x0040D6E9 in sqlservr.exe, sequencer () + 0x0049
				

Modification Type:MajorLast Reviewed:10/3/2003
Keywords:kbBug kbpending KB264189