WindowsXP/admin/wmi/wbem/winmgmt/specs/html/subclassprovsandqueries.htm
2025-04-27 07:49:33 -04:00

140 lines
5.0 KiB
HTML

<html>
<head>
<title>Memo </title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body bgcolor="#C0C0C0" text="#000080">
<p><big><big><u><font color="#800080">WMI Core Memo </font>: Subclass Providers and
Queries</u></big></big></p>
<p>Rev 1.00, raymcc, Jul-16-99</p>
<hr>
<p><strong>1.0 Introduction</strong></p>
<p>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.</p>
<p>Specifically, in order to avoid orphaned instances, the result sets of two providers
which are chained together in a class hierarchy must match exactly.&nbsp; Given that the
subclass provider <em>may </em>override one or more properties, the providers may not
agree on the sets of instances which are returned.</p>
<p><strong>Cf. RAID 54070.</strong></p>
<hr>
<p><strong>2.0&nbsp; Example</strong></p>
<p>Assume the following class hierarachy, where instances of each class are provided by
providers which support queries:</p>
<p><strong>&nbsp;</strong></p>
<blockquote>
<p>[dynamic, provider(&quot;abc&quot;)]<br>
class MyClass<br>
{<br>
&nbsp;&nbsp;&nbsp; [key] sint32 ID;<br>
&nbsp;&nbsp;&nbsp; sint32 p1;<br>
&nbsp;&nbsp;&nbsp; sint32 p2;</p>
<p>[dynamic, provider(&quot;xyz&quot;)]<br>
class Subclass : MyClass<br>
{<br>
&nbsp;&nbsp;&nbsp; [override] sint32 p2;<br>
&nbsp;&nbsp;&nbsp; sint32 p3;<br>
}</p>
</blockquote>
<p>If the client issues a query <em>select * from MyClass where p2 = 1 </em>the first
provider <strong>abc </strong>may determine that there are no instances in which <em>p2 =
1</em> and return an empty result set.&nbsp;&nbsp; The second provider, for <em>Subclass</em>,
which will be called during the execution of the query, may in fact believe that there are
several instances where <em>p2=1 </em>and return several instances.&nbsp; These instances
must be joined to instances of <em>MyClass, </em>which do not actually exist.&nbsp; </p>
<p>Thus, the overridden property has introduced a conflict in the result set.</p>
<hr>
<p><strong>3.0&nbsp; MOF Conventions</strong></p>
<p>Strictly speaking, if a property is overridden in a subclass, it <em>must </em>be
marked with the <strong>override </strong>qualifier.&nbsp;&nbsp; WinMgmt will enforce this
in Win2000.</p>
<blockquote>
<p>class MyClass<br>
{<br>
&nbsp;&nbsp;&nbsp; [key] sint32 ID;<br>
&nbsp;&nbsp;&nbsp; sint32 p1;<br>
&nbsp;&nbsp;&nbsp; sint32 p2;</p>
<p>class Subclass : MyClass<br>
{<br>
&nbsp;&nbsp;&nbsp; [override] sint32 p2;<br>
&nbsp;&nbsp;&nbsp; sint32 p3;<br>
}</p>
</blockquote>
<p>This allows WinMmgt to detect that there may be a conflict in how the providers
determine correct result sets.</p>
<hr>
<p><strong>4.0&nbsp; Providers and Clients</strong></p>
<p>There is no change involved in provider construction or in the way clients issue their
queries.&nbsp; This issue is solved entirely within WMI Core Components.</p>
<p>The only rule, <strong>still enforced, </strong>is that subclass providers and
superclass providers must return the same set of instances with regard to key values.
&nbsp; A subclass provider may provide <em>less </em>instances than the set of instances
provided by the superclass provider, but may not return <em>more</em><strong> </strong>instances.</p>
<hr>
<p><strong>5.0 WinMgmt Modifications</strong></p>
<p>WinMmgt will be modified as a result of RAI D 54070 to change the queries it submits to
providers.&nbsp; In the simplest cases, changing to pure enumeration would solve the
problem.&nbsp;&nbsp; However, many providers can support queries and considerable
optimizations would be lost.</p>
<p>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.&nbsp; If the
client issues the following query:</p>
<p>&nbsp;&nbsp;&nbsp; <em>select * from MyClass where ID &gt; 10 and p1 &lt; 100 and p2
&gt; 200</em></p>
<p>Then the query supplied to the superclass provider would be</p>
<p>&nbsp;&nbsp;&nbsp; <em>select * from MyClass where ID &gt; 10 and p1 &lt; 100</em></p>
<p>It is not correct for the superclass provider to know that an additional test of <em>p2
&gt; 200 </em>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.</p>
<p>Since subclass providers may only support enumeration, or vice-versa, WinMgmt will
customize the query for the provider, following the above guidelines.
&nbsp;&nbsp; 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.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><em>&nbsp;</em></p>
<p><strong>&nbsp;</strong></p>
</body>
</html>