Microsoft KB Archive/299544

= FIX: Correlated Subquery Containing UNION ALL May Cause Access Violation =

Article ID: 299544

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q299544



BUG #: 351658 (SHILOH_BUGS)



SYMPTOMS
If a correlated subquery uses the UNION ALL clause, SQL Server may produce an access violation (AV) and stack trace.



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 the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack



WORKAROUND
Avoid the use of the UNION ALL clause.



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
The following query demonstrates the problem: Use northwind go SELECT LastName, (SELECT SUM(CONVERT(int,extension))  FROM   (select * from employees e1      where e1.reportsto = e0.employeeid and city = 'seattle' UNION ALL select * from employees e2     where e2.reportsto = e0.employeeid and city = 'london') as reportsInSeattleAndLondon ) FROM employees e0 The SQL Server Errorlog may contain a stack trace that resembles the following: 0055AA6C Module(sqlservr+0015AA6C) (CBitSet::FGetNext(class CBitSetToken &,unsigned long &)const +0000001A) 0055A9F9 Module(sqlservr+0015A9F9) (CPvrBitSet::FGetNext(class CPvrBitSetToken &,class CValRef * &)const +0000001D) 00594916 Module(sqlservr+00194916) (CTableGroupProperties::FAnyUsedColsAreBound(class CPvrBitSet *)+00000025) 007BB09D Module(sqlservr+003BB09D) (CSubRuleApplyHandlerBase::FInnerColsFunctionallyDetermined(class DRgPExpr *,class CTableGroupProperties *,class DRgCId *)+0000003D) 007BB313 Module(sqlservr+003BB313) (CSubRuleApplyHandlerBase::FSubstSGb(class COptExpr *,class CTableGroupProperties *,class COptExpr *,class COptExpr * *,class DRgPExpr *,class CTDynArray > *,class DRgPExpr 007BC0B8 Module(sqlservr+003BC0B8) (CSubRuleApplyHandlerBase::BuildSubstitutes(class COptExpr *,class CRuleContext *,class CRuleReturn *)+0000015C) 0055D6CF Module(sqlservr+0015D6CF) (COptContext::PexprTransformTopLevel(class COptExpr *,class CActiveRuleArray *,class CMoveSorter *)+0000019E) 0055D846 Module(sqlservr+0015D846) (COptContext::PexprNormalize(class COptExpr *,class CActiveRuleArray *,class CMoveSorter *)+00000034) 0055E8F1 Module(sqlservr+0015E8F1) (CMemo::NormalizeQuery(class CQuery *,class COptExpr *)+0000006E) 0055E7B6 Module(sqlservr+0015E7B6) (COptContext::PexprSimplify(class COptExpr *)+000000F6) 0055DE4F Module(sqlservr+0015DE4F) (COptContext::PcxteOptimizeQuery(class COptExpr *,class DRgCId *)+000004E5) 0055FFBB Module(sqlservr+0015FFBB) (CQuery::Optimize(void)+00000416) 0055FD54 Module(sqlservr+0015FD54) (CQuery::Optimize(unsigned long)+00000030) 005642C6 Module(sqlservr+001642C6) (CCvtTree::PqryFromTree(class TREE *,class IMemObj *,class CRangeCollection *,unsigned long,class CCompPlan *)+000002C4) 00564019 Module(sqlservr+00164019) (BuildQueryFromTree(class TREE *,class IMemObj *,class IMemObj *,class IQueryObj * *,class CRangeCollection *,unsigned long,class CCompPlan *)+00000046) 00563F78 Module(sqlservr+00163F78) (CStmtQuery::InitQuery(class CAlgStmt *,class CCompPlan *,unsigned long)+0000014B) 0049DA48 Module(sqlservr+0009DA48) (CStmtSelect::Init(class CAlgStmt *,class CCompPlan *,class IBrowseMode *)+00000091) 00447078 Module(sqlservr+00047078) (CCompPlan::FCompileStep(class CAlgStmt *,class CStatement * *)+00000AE7) 004510FE Module(sqlservr+000510FE) (CProchdr::FCompile(class CCompPlan *,class CParamExchange *)+00000D15) 00415080 Module(sqlservr+00015080) (CSQLSource::FTransform(class CParamExchange *)+0000037C) 004592CE Module(sqlservr+000592CE) (CSQLStrings::FTransform(class CParamExchange *)+000001A8) 0041534F Module(sqlservr+0001534F) (CSQLSource::Execute(class CParamExchange *)+00000176) 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)

Keywords: kbbug kbfix kbsqlserv2000sp1fix KB299544

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.