BUG: Complex Query Containing Redundant Logic May Cause Access Violation

ID: Q232926


The information in this article applies to:

BUG #: 54578 (SQLBUG_70)

SYMPTOMS

A complex query that includes logically redundant code may cause a handled access violation (AV) when the Query Optimizer attempts to remove the unnecessary logic at compile time.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next SQL Server service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The English version of this fix should have the following file attributes or later:

   Version          Size      File name    Platform
   ------------------------------------------------

   7.00.0661       86,288    Impprov.dll   (Intel)
   7.00.0661    4,976,912   Sqlservr.exe   (Intel)
   7.00.0661      116,736    Impprov.dll   (Alpha)
   7.00.0661   11,801,872   Sqlservr.exe   (Alpha) 
NOTE: Due to file dependencies, the most recent hotfix or feature that contains the above files may also contain additional files.


NOTE: If this product was already installed on your computer when you purchased it from the Original Equipment Manufacturer (OEM) and you need this fix, please call the Pay Per Incident number listed on the above Web site. If you contact Microsoft to obtain this fix, and if it is determined that you only require the fix you requested, no fee will be charged. However, if you request additional technical support, and if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support, you may be charged a non-refundable fee.

For more information about eligibility for no-charge technical support, see the following article in the Microsoft Knowledge Base:
Q154871 Determining If You Are Eligible for No-Charge Technical Support


WORKAROUND

To work around this problem, avoid using logical redundancy in complex SQL queries.


STATUS

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


MORE INFORMATION

For example, the following query can be said to contain logically redundant code:


select stor_id, isnull(isnull(qty,0),0) quantity
   from pubs..sales
   where ord_num = 'P3087a' 
The outer ISNULL() function is unnecessary because the nested ISNULL() will never return NULL. In fact, neither ISNULL() function is necessary because the qty column of the sales table does not permit NULL values.

The Query Optimizer in SQL Server 7.0 attempts to make queries more efficient by eliminating unnecessary logic like that shown above (a technique referred to as "Folding"). It is during this phase of optimization with a highly complex query that SQL Server may encounter the AV described in this article.

Additional query words:


Keywords          : SSrvGPF kbbug7.00 
Version           : winnt:7.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: July 2, 1999