WMI Core Memo : Subclass Providers and Queries

Rev 1.00, raymcc, Jul-16-99


1.0 Introduction

This memo concerns an inconsistency found on 16-Jul-99 within WinMmgt concerning providers which support queries and which are also involved in a class hierarchy where multiple providers are subclassing the same base class.

Specifically, in order to avoid orphaned instances, the result sets of two providers which are chained together in a class hierarchy must match exactly.  Given that the subclass provider may override one or more properties, the providers may not agree on the sets of instances which are returned.

Cf. RAID 54070.


2.0  Example

Assume the following class hierarachy, where instances of each class are provided by providers which support queries:

 

[dynamic, provider("abc")]
class MyClass
{
    [key] sint32 ID;
    sint32 p1;
    sint32 p2;

[dynamic, provider("xyz")]
class Subclass : MyClass
{
    [override] sint32 p2;
    sint32 p3;
}

If the client issues a query select * from MyClass where p2 = 1 the first provider abc may determine that there are no instances in which p2 = 1 and return an empty result set.   The second provider, for Subclass, which will be called during the execution of the query, may in fact believe that there are several instances where p2=1 and return several instances.  These instances must be joined to instances of MyClass, which do not actually exist. 

Thus, the overridden property has introduced a conflict in the result set.


3.0  MOF Conventions

Strictly speaking, if a property is overridden in a subclass, it must be marked with the override qualifier.   WinMgmt will enforce this in Win2000.

class MyClass
{
    [key] sint32 ID;
    sint32 p1;
    sint32 p2;

class Subclass : MyClass
{
    [override] sint32 p2;
    sint32 p3;
}

This allows WinMmgt to detect that there may be a conflict in how the providers determine correct result sets.


4.0  Providers and Clients

There is no change involved in provider construction or in the way clients issue their queries.  This issue is solved entirely within WMI Core Components.

The only rule, still enforced, is that subclass providers and superclass providers must return the same set of instances with regard to key values.   A subclass provider may provide less instances than the set of instances provided by the superclass provider, but may not return more instances.


5.0 WinMgmt Modifications

WinMmgt will be modified as a result of RAI D 54070 to change the queries it submits to providers.  In the simplest cases, changing to pure enumeration would solve the problem.   However, many providers can support queries and considerable optimizations would be lost.

WinMgmt will be altered to change the client's query to a subset of the query which eliminates any mention of properties overridden in a subclass provider.  If the client issues the following query:

    select * from MyClass where ID > 10 and p1 < 100 and p2 > 200

Then the query supplied to the superclass provider would be

    select * from MyClass where ID > 10 and p1 < 100

It is not correct for the superclass provider to know that an additional test of p2 > 200 was present on the query, because it cannot know if the subclass provider will override the value for any given instance, thus changing the result set.

Since subclass providers may only support enumeration, or vice-versa, WinMgmt will customize the query for the provider, following the above guidelines.    Likewise, since the subclass provider which can support queries doesn't know about superclass property values that it hasn't overriden, these will be removed from the queries to the subclass providers.