Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

958 lines
29 KiB

  1. /*++
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. WQLNODE.H
  5. Abstract:
  6. WMI SQL Parse Node Definitions
  7. History:
  8. raymcc 29-Sep-97 Created
  9. --*/
  10. #ifndef _WQLNODE_H_
  11. #define _WQLNODE_H_
  12. #define WQL_FLAG_ALIAS 0x1
  13. #define WQL_FLAG_TABLE 0x2
  14. #define WQL_FLAG_ASTERISK 0x4
  15. #define WQL_FLAG_DISTINCT 0x8
  16. #define WQL_FLAG_ALL 0x10
  17. #define WQL_FLAG_COUNT 0x20
  18. #define WQL_FLAG_CONST 0x40
  19. #define WQL_FLAG_COLUMN 0x80
  20. #define WQL_FLAG_COMPLEX_NAME 0x100
  21. #define WQL_FLAG_FUNCTIONIZED 0x200
  22. #define WQL_FLAG_ARRAY_REF 0x400
  23. #define WQL_FLAG_UPPER 0x800
  24. #define WQL_FLAG_LOWER 0x1000
  25. #define WQL_FLAG_FIRSTROW 0x2000
  26. #define WQL_FLAG_CONST_RANGE 0x4000
  27. #define WQL_FLAG_SORT_ASC 0x8000
  28. #define WQL_FLAG_SORT_DESC 0x10000
  29. #define WQL_FLAG_AGGREGATE 0x20000
  30. #define WQL_FLAG_NULL 0x40000
  31. #define WQL_FLAG_INNER_JOIN 1
  32. #define WQL_FLAG_LEFT_OUTER_JOIN 2
  33. #define WQL_FLAG_RIGHT_OUTER_JOIN 3
  34. #define WQL_FLAG_FULL_OUTER_JOIN 4
  35. #define WQL_TOK_BASE 100
  36. #include <wmiutils.h>
  37. class CWbemAssocQueryInf : public SWbemAssocQueryInf
  38. {
  39. public:
  40. CWbemAssocQueryInf();
  41. ~CWbemAssocQueryInf();
  42. void Empty();
  43. void Init();
  44. HRESULT CopyFrom(SWbemAssocQueryInf *pSrc);
  45. };
  46. //***************************************************************************
  47. //
  48. // SWQLNode
  49. //
  50. // Base node type for all parser output.
  51. //
  52. //***************************************************************************
  53. struct SWQLNode
  54. {
  55. DWORD m_dwNodeType;
  56. SWQLNode *m_pLeft;
  57. SWQLNode *m_pRight;
  58. SWQLNode() { m_pLeft = 0; m_pRight = 0; m_dwNodeType = 0; }
  59. virtual ~SWQLNode() { if (m_pLeft) delete m_pLeft; if (m_pRight) delete m_pRight; }
  60. virtual void DebugDump() = 0;
  61. };
  62. //***************************************************************************
  63. //
  64. // SWQLNode_QueryRoot
  65. //
  66. // This is the root of the parse tree. The child nodes are for one of
  67. // SELECT, INSERT, UPDATE, DELETE.
  68. //
  69. // SWQLQueryRoot
  70. // / \
  71. // SWQLNode_Select NULL
  72. // or SWQLNode_Insert
  73. // or SWQLNode_Delete
  74. // or SWQLNode_Update
  75. // or SWQLNode_AssocQuery
  76. //
  77. //***************************************************************************
  78. #define TYPE_SWQLNode_QueryRoot (WQL_TOK_BASE + 1)
  79. struct SWQLNode_QueryRoot : SWQLNode
  80. {
  81. enum { eInvalid = 0, eSelect, eInsert, eDelete, eUpdate, eAssoc };
  82. DWORD m_dwQueryType;
  83. SWQLNode_QueryRoot() { m_dwNodeType = TYPE_SWQLNode_QueryRoot; m_dwQueryType = 0; }
  84. ~SWQLNode_QueryRoot() {}
  85. void DebugDump();
  86. };
  87. //***************************************************************************
  88. //
  89. // SWQLTypedConst
  90. //
  91. // Typed constant container (similar to OA VARIANT).
  92. //
  93. //***************************************************************************
  94. union UWQLTypedConst
  95. {
  96. LPWSTR m_pString; // VT_LPWSTR for WQL_TOK_QSTRING and WQL_TOK_PROMPT
  97. LONG m_lValue; // VT_LONG
  98. double m_dblValue; // VT_DOUBLE
  99. __int64 m_i64Value; // VT_I8, VT_UI8
  100. BOOL m_bValue; // VT_BOOL, use TRUE/FALSE (not VARIANT_TRUE, VARIANT_FALSE)
  101. };
  102. struct SWQLTypedConst
  103. {
  104. DWORD m_dwType; // A VT_ type, VT_UI4, VT_I8, VT_UI8 all supported
  105. UWQLTypedConst m_Value; // One of the union fields
  106. bool m_bPrompt; // Only true if token was WQL_TOK_PROMPT
  107. SWQLTypedConst();
  108. SWQLTypedConst(SWQLTypedConst &Src) { m_dwType = VT_NULL; *this = Src; }
  109. SWQLTypedConst & operator = (SWQLTypedConst &Src);
  110. ~SWQLTypedConst() { Empty(); }
  111. void Empty();
  112. void DebugDump();
  113. };
  114. struct SWQLConstList
  115. {
  116. CFlexArray m_aValues; // ptrs to SWQLTypedConst
  117. SWQLConstList() {}
  118. SWQLConstList(SWQLConstList &Src) { *this = Src; }
  119. SWQLConstList & operator = (SWQLConstList & Src);
  120. ~SWQLConstList() { Empty(); }
  121. int Add(SWQLTypedConst *pTC) { return m_aValues.Add(pTC); }
  122. void Empty();
  123. };
  124. struct SWQLQualifiedNameField
  125. {
  126. LPWSTR m_pName; // Name
  127. BOOL m_bArrayRef; // TRUE if this is an array reference
  128. DWORD m_dwArrayIndex; // If <m_bArrayRef == TRUE> this is the array index
  129. SWQLQualifiedNameField() { m_pName = 0; m_bArrayRef = 0; m_dwArrayIndex = 0; }
  130. SWQLQualifiedNameField(SWQLQualifiedNameField &Src) { m_pName = 0; *this = Src; }
  131. SWQLQualifiedNameField & operator = (SWQLQualifiedNameField &Src);
  132. ~SWQLQualifiedNameField() { Empty(); }
  133. private:
  134. void Empty() { delete [] m_pName; m_pName = 0; }
  135. };
  136. struct SWQLQualifiedName
  137. {
  138. CFlexArray m_aFields; // [0] = left most, last entry is column
  139. SWQLQualifiedName() {}
  140. SWQLQualifiedName(SWQLQualifiedName &Src) { *this = Src; }
  141. SWQLQualifiedName & operator = (SWQLQualifiedName &Src);
  142. ~SWQLQualifiedName() { Empty(); }
  143. int GetNumNames() { return m_aFields.Size(); }
  144. const LPWSTR GetName(int nIndex)
  145. {
  146. return (LPWSTR) ((SWQLQualifiedNameField*) m_aFields[nIndex])->m_pName;
  147. }
  148. int Add(SWQLQualifiedNameField *pQN) { return m_aFields.Add(pQN); }
  149. void Empty()
  150. {
  151. for (int i = 0; i < m_aFields.Size(); i++)
  152. delete (SWQLQualifiedNameField *) m_aFields[i];
  153. }
  154. };
  155. //***************************************************************************
  156. //
  157. // SWQLNode_Select
  158. //
  159. // This is the root of the parse tree or the root of a subselect.
  160. //
  161. // SWQLNode_Select
  162. // / \
  163. // SWQLNode_TableRefs SWQLNode_WhereClause
  164. // / \ / \
  165. // x x x x
  166. //
  167. //***************************************************************************
  168. #define TYPE_SWQLNode_Select (WQL_TOK_BASE + 2)
  169. struct SWQLNode_Select : SWQLNode
  170. {
  171. // Left Node is of type SWQLNode_TableRefs
  172. // Right Node is of type SWQLNode_WhereClause
  173. int m_nStPos;
  174. int m_nEndPos;
  175. SWQLNode_Select() : m_nStPos(-1), m_nEndPos(-1) { m_dwNodeType = TYPE_SWQLNode_Select; }
  176. void DebugDump();
  177. };
  178. //***************************************************************************
  179. //
  180. // SWQLNode_TableRefs
  181. //
  182. // This contains everything prior to the WHERE clause: the target
  183. // column list and the FROM clause.
  184. //
  185. // Also contains the SELECT type, i.e., ALL vs. DISTINCT vs. COUNT.
  186. //
  187. // SWQLNode_TableRefs
  188. // / \
  189. // SWQLNode_ColumnList SWQLNode_FromClause
  190. //
  191. // In all cases, SWQLNode_ColumnList is present. Note that if the
  192. // user did a "select *...", then the SWQLNode_ColumnList will only
  193. // have a single column in it clearly marked as an asterisk. If
  194. // a "select count(...) " was done, then m_nSelectType is set to
  195. // WQL_FLAG_COUNT and the SWQLNode_ColumnList will have a single
  196. // column in it, whether an * or a qualified name.
  197. //
  198. //***************************************************************************
  199. #define TYPE_SWQLNode_TableRefs (WQL_TOK_BASE + 3)
  200. struct SWQLNode_TableRefs : SWQLNode
  201. {
  202. // Left Node is SWQLNode_ColumnList
  203. // Right Node is SWQLNode_FromClause
  204. int m_nSelectType; // WQL_FLAG_ALL means ALL was used.
  205. // WQL_FLAG_DISTINCT means DISTINCT was used.
  206. // WQL_FLAG_COUNT means COUNT was used.
  207. SWQLNode_TableRefs()
  208. { m_nSelectType = WQL_FLAG_ALL;
  209. m_dwNodeType = TYPE_SWQLNode_TableRefs;
  210. }
  211. ~SWQLNode_TableRefs() {}
  212. void DebugDump();
  213. };
  214. //***************************************************************************
  215. //
  216. // SWQLNode_ColumnList
  217. //
  218. // This contains the selected list of columns.
  219. //
  220. // SWQLNode_ColumnList
  221. // / \
  222. // NULL NULL
  223. //
  224. //***************************************************************************
  225. #define TYPE_SWQLNode_ColumnList (WQL_TOK_BASE + 4)
  226. struct SWQLNode_ColumnList : SWQLNode
  227. {
  228. // Left Node is NULL
  229. // Right Node is NULL
  230. CFlexArray m_aColumnRefs ; // Pointers to SWQLColRef entries.
  231. SWQLNode_ColumnList() { m_dwNodeType = TYPE_SWQLNode_ColumnList; }
  232. ~SWQLNode_ColumnList() { Empty(); }
  233. void Empty();
  234. void DebugDump();
  235. };
  236. struct SWQLColRef
  237. {
  238. LPWSTR m_pColName; // The column name or "*" or NULL
  239. LPWSTR m_pTableRef; // The table/alias name or NULL if there is none
  240. DWORD m_dwArrayIndex;
  241. DWORD m_dwFlags; // WQL_FLAG_TABLE bit set if m_pTableRef
  242. // is a table name
  243. // WQL_FLAG_ALIAS bit set if m_pTableRef
  244. // is a table alias
  245. // WQL_FLAG_ASTERISK bit set if m_pColName is
  246. // * (this is faster than to check than a
  247. // string compare on <m_pColName> for "*".
  248. // WQL_FLAG_NULL if the column name was "NULL"
  249. // WQL_FLAG_FUNCTIONIZED is set if the column
  250. // is wrapped in a function call.
  251. // The function bits WQL_FLAG_UPPER or
  252. // WQL_FLAG_LOWER will be set.
  253. // WQL_FLAG_ARRAY_REF is set if the column
  254. // is an array column, in which case
  255. // m_dwArrayIndex is set to the array offset.
  256. // WQL_FLAG_COMPLEX_NAME is set if the name
  257. // is qualified in a deeply nested way,
  258. // which requires examination of the <QName>
  259. // object. In this case <m_pColName> is
  260. // set to the last name, but m_pTableRef
  261. // is left blank.
  262. // WQL_FLAG_SORT_ASC to sort ascending (Order by only)
  263. // WQL_FLAG_SORT_DESC to sort descending (Order by only)
  264. SWQLQualifiedName *m_pQName; // The full qualified name
  265. SWQLColRef() { m_pColName = NULL; m_pTableRef = 0;
  266. m_dwFlags = 0; m_dwArrayIndex = 0; m_pQName = 0;
  267. }
  268. ~SWQLColRef() { delete [] m_pColName; delete [] m_pTableRef; delete m_pQName; }
  269. //
  270. // we are inlining to remove a compiler dependency in wbemcomn
  271. //
  272. void DebugDump()
  273. {
  274. printf(" ---SWQLColRef---\n");
  275. printf(" Col Name = %S\n", m_pColName);
  276. printf(" Table = %S\n", m_pTableRef);
  277. printf(" Array Index = %d\n", m_dwArrayIndex);
  278. printf(" Flags = 0x%X ", m_dwFlags);
  279. if (m_dwFlags & WQL_FLAG_TABLE)
  280. printf("WQL_FLAG_TABLE ");
  281. if (m_dwFlags & WQL_FLAG_COLUMN)
  282. printf("WQL_FLAG_COLUMN ");
  283. if (m_dwFlags & WQL_FLAG_ASTERISK)
  284. printf("WQL_FLAG_ASTERISK ");
  285. if (m_dwFlags & WQL_FLAG_NULL)
  286. printf("WQL_FLAG_NULL ");
  287. if (m_dwFlags & WQL_FLAG_FUNCTIONIZED)
  288. printf("WQL_FLAG_FUNCTIONIZED ");
  289. if (m_dwFlags & WQL_FLAG_COMPLEX_NAME)
  290. printf("WQL_FLAG_COMPLEX_NAME ");
  291. if (m_dwFlags & WQL_FLAG_ARRAY_REF)
  292. printf(" WQL_FLAG_ARRAY_REF");
  293. if (m_dwFlags & WQL_FLAG_UPPER)
  294. printf(" WQL_FLAG_UPPER");
  295. if (m_dwFlags & WQL_FLAG_LOWER)
  296. printf(" WQL_FLAG_LOWER");
  297. if (m_dwFlags & WQL_FLAG_SORT_ASC)
  298. printf(" WQL_FLAG_SORT_ASC");
  299. if (m_dwFlags & WQL_FLAG_SORT_DESC)
  300. printf(" WQL_FLAG_SORT_DESC");
  301. printf("\n");
  302. printf(" ---\n\n");
  303. }
  304. };
  305. //***************************************************************************
  306. //
  307. // SWQLNode_FromClause
  308. //
  309. // The subtree containing the tables selected from and any joins.
  310. //
  311. // SWQLNode_FromClause
  312. // / \
  313. // SWQLNode_TableRef SWQLNode_WmiScopedSelect
  314. // or SWQLNode_Join
  315. // or SWQLNode_Sql89Join
  316. //
  317. // Note that left and right nodes are mutually exclusive. Either
  318. // the left side is used for traditional SQL or the right side is
  319. // used for the WMI scoped select.
  320. //
  321. //***************************************************************************
  322. #define TYPE_SWQLNode_FromClause (WQL_TOK_BASE + 5)
  323. struct SWQLNode_FromClause : SWQLNode
  324. {
  325. // Left is SWQLNode_TableRef or SWQLNode_Join
  326. // Right is NULL
  327. SWQLNode_FromClause() { m_dwNodeType = TYPE_SWQLNode_FromClause; }
  328. ~SWQLNode_FromClause() {}
  329. void DebugDump();
  330. };
  331. //***************************************************************************
  332. //
  333. // SWQLNode_WmiScopedSelect
  334. //
  335. // SWQLNode_WmiScopedSelect
  336. // / \
  337. // NULL NULL
  338. //
  339. //
  340. // Contains a special-case selection for WMI v2. The syntax is
  341. //
  342. // FROM '['<object path>']' <class-list>
  343. //
  344. // ...where <class-list> is either a single class or a curly-bracket-delimited
  345. // list of classes, separated by commas:
  346. //
  347. // FROM [scope.p1=2] MyClass
  348. // FROM [scope.p1=2] {MyClass}
  349. // FROM [scope.p1=2] {MyClass, MyClass2}
  350. //
  351. //
  352. //***************************************************************************
  353. #define TYPE_SWQLNode_WmiScopedSelect (WQL_TOK_BASE + 6)
  354. struct SWQLNode_WmiScopedSelect : SWQLNode
  355. {
  356. LPWSTR m_pszScope;
  357. CFlexArray m_aTables;
  358. SWQLNode_WmiScopedSelect()
  359. { m_dwNodeType = TYPE_SWQLNode_FromClause;
  360. m_pszScope = 0;
  361. }
  362. ~SWQLNode_WmiScopedSelect()
  363. {
  364. for (int i = 0; i < m_aTables.Size(); i++)
  365. delete LPWSTR(m_aTables[i]);
  366. delete m_pszScope;
  367. }
  368. void DebugDump();
  369. };
  370. //***************************************************************************
  371. //
  372. // SWQLNode_Sql89Join
  373. //
  374. // A subtree which expresses a SQL-89 join.
  375. //
  376. // SWQLNode_Sql89Join
  377. // / \
  378. // NULL NULL
  379. //
  380. //***************************************************************************
  381. #define TYPE_SWQLNode_Sql89Join (WQL_TOK_BASE + 7)
  382. struct SWQLNode_Sql89Join : SWQLNode
  383. {
  384. CFlexArray m_aValues; // Array of pointers to SWQLNode_TableRef
  385. // objects
  386. SWQLNode_Sql89Join() { m_dwNodeType = TYPE_SWQLNode_Sql89Join; }
  387. ~SWQLNode_Sql89Join() {Empty();};
  388. void DebugDump();
  389. void Empty();
  390. };
  391. //***************************************************************************
  392. //
  393. // SWQLNode_Join
  394. //
  395. // A subtree which expresses a join.
  396. //
  397. // SWQLNode_Join
  398. // / \
  399. // SWQLNode_JoinPair SWQLNode_OnClause or NULL.
  400. //
  401. //***************************************************************************
  402. #define TYPE_SWQLNode_Join (WQL_TOK_BASE + 8)
  403. struct SWQLNode_Join : SWQLNode
  404. {
  405. // Left ptr is SWQLNode_JoinPair
  406. // Right ptr is ON clause. If NULL, there is no ON clause
  407. // and the JOIN was a SQL-89 style join with the join condition
  408. // present in the WHERE clause.
  409. DWORD m_dwJoinType;
  410. // One of WQL_FLAG_INNER_JOIN, WQL_FLAG_LEFT_OUTER_JOIN,
  411. // WQL_FLAG_RIGHT_OUTER_JOIN or WQL_FLAG_FULL_OUTER_JOIN
  412. DWORD m_dwFlags;
  413. // Contains WQL_FLAG_FIRSTROW if used
  414. SWQLNode_Join() { m_dwNodeType = TYPE_SWQLNode_Join; m_dwJoinType = m_dwFlags = 0; }
  415. ~SWQLNode_Join() {}
  416. void DebugDump();
  417. };
  418. //***************************************************************************
  419. //
  420. // SWQLNode_JoinPair
  421. //
  422. // SWQLNode_JoinPair
  423. // / \
  424. // <SWQLNode_Join or SWQLNode_TableRef>
  425. //
  426. //***************************************************************************
  427. #define TYPE_SWQLNode_JoinPair (WQL_TOK_BASE + 9)
  428. struct SWQLNode_JoinPair : SWQLNode
  429. {
  430. // Left ptr is SWQLNode_Join or SWQLNode_TableRef
  431. // Right ptr is SWQLNodeNode_Join or SWQL_NodeTableRef
  432. SWQLNode_JoinPair() { m_dwNodeType = TYPE_SWQLNode_JoinPair; }
  433. ~SWQLNode_JoinPair() {}
  434. void DebugDump();
  435. };
  436. //***************************************************************************
  437. //
  438. // SWQLNode_TableRef
  439. //
  440. // A node representing a table name and its alias, if any.
  441. //
  442. // SWQLNode_TableRef
  443. // / \
  444. // NULL NULL
  445. //
  446. //***************************************************************************
  447. #define TYPE_SWQLNode_TableRef (WQL_TOK_BASE + 10)
  448. struct SWQLNode_TableRef : SWQLNode
  449. {
  450. LPWSTR m_pTableName; // The table
  451. LPWSTR m_pAlias; // Table alias. NULL if not used.
  452. SWQLNode_TableRef() { m_pTableName = 0; m_pAlias = 0; m_dwNodeType = TYPE_SWQLNode_TableRef; }
  453. ~SWQLNode_TableRef() { delete [] m_pTableName; delete [] m_pAlias; }
  454. void DebugDump();
  455. };
  456. //***************************************************************************
  457. //
  458. // SWQLNode_OnClause
  459. //
  460. // SWQLNode_OnClause
  461. // / \
  462. // <SWQLNode_RelExpr> NULL
  463. //
  464. //***************************************************************************
  465. #define TYPE_SWQLNode_OnClause (WQL_TOK_BASE + 11)
  466. struct SWQLNode_OnClause : SWQLNode
  467. {
  468. // Left ptr is <SWQLNode_RelExpr> which contains the ON clause.
  469. // Right ptr is always NULL.
  470. SWQLNode_OnClause() { m_dwNodeType = TYPE_SWQLNode_OnClause; }
  471. ~SWQLNode_OnClause() {}
  472. void DebugDump();
  473. };
  474. //***************************************************************************
  475. //
  476. // SWQLNode_WhereClause
  477. //
  478. // SWQLNode_WhereClause
  479. // / \
  480. // SWQLNode_RelExpr SWQLNode_WhereOptions or NULL
  481. // or
  482. // NULL if no conditions
  483. //
  484. //***************************************************************************
  485. #define TYPE_SWQLNode_WhereClause (WQL_TOK_BASE + 12)
  486. struct SWQLNode_WhereClause : SWQLNode
  487. {
  488. // Left ptr is SWQLNode_RelExpr.
  489. // Right ptr is SQLNode_QueryOptions or NULL if none
  490. SWQLNode_WhereClause() { m_dwNodeType = TYPE_SWQLNode_WhereClause; }
  491. ~SWQLNode_WhereClause() {}
  492. void DebugDump();
  493. };
  494. //***************************************************************************
  495. //
  496. // struct SWQLTypedExpr
  497. //
  498. // This represents a typed subexpression in a where clause:
  499. //
  500. // mycol < 2
  501. // 33 <= tbl1.col2
  502. // tbl3.col4 = tbl4.col5
  503. // ...etc.
  504. //
  505. //***************************************************************************
  506. struct SWQLTypedExpr
  507. {
  508. LPWSTR m_pTableRef; // For qualified column names,
  509. // NULL if not used
  510. LPWSTR m_pColRef; // Column name
  511. DWORD m_dwRelOperator; // The operator used: WQL_TOK_LE,
  512. // WQL_TOK_GE, WQL_TOK_LIKE etc.
  513. // WQL_TOK_IN_CONST_LIST
  514. // WQL_TOK_NOT_IN_CONST_LIST
  515. // WQL_TOK_IN_SUBSELECT
  516. // WQL_TOK_NOT_IN_SUBSELECT
  517. SWQLTypedConst *m_pConstValue; // A const value
  518. SWQLTypedConst *m_pConstValue2; // The other const value used with BETWEEN
  519. LPWSTR m_pJoinTableRef; // The joined table name or its alias,
  520. // NULL if not used
  521. LPWSTR m_pJoinColRef; // The joined column name
  522. LPWSTR m_pIntrinsicFuncOnColRef;
  523. LPWSTR m_pIntrinsicFuncOnJoinColRef;
  524. LPWSTR m_pIntrinsicFuncOnConstValue;
  525. SWQLNode *m_pLeftFunction; // More detail for DATEPART, etc.
  526. SWQLNode *m_pRightFunction; // More detail for DATEPART, etc.
  527. DWORD m_dwLeftArrayIndex;
  528. DWORD m_dwRightArrayIndex;
  529. SWQLQualifiedName *m_pQNRight;
  530. SWQLQualifiedName *m_pQNLeft;
  531. DWORD m_dwLeftFlags;
  532. DWORD m_dwRightFlags;
  533. // Each of the above to Flags shows the expression layout on each side
  534. // of the operator.
  535. // WQL_FLAG_CONST = A typed constant was used
  536. // WQL_FLAG_COLUMN = Column field was used
  537. // WQL_FLAG_TABLE = Table/Alias was used
  538. // WQL_FLAG_COMPLEX = Complex qualified name and/or array was used
  539. // WQL_FLAG_FUNCTIONIZED = Function was applied over the const or col.
  540. // For IN and NOT IN clauses.
  541. // ==========================
  542. SWQLNode *m_pSubSelect;
  543. SWQLConstList *m_pConstList; // For IN clause with constant-list
  544. /*
  545. (1) If a const is tested against a column, then <m_pConstValue> will
  546. be used to represent it, and the table+col referenced will be in
  547. <m_pTableRef> and <m_pColRef>.
  548. (2) If a join occurs, then <m_pConstValue> will be NULL.
  549. (3) Intrinsic functions (primarily UPPER() and LOWER()) can be applied
  550. to the column references or the constant. The function names will
  551. be placed in the <m_pIntrinsic...> pointers when applied.
  552. (4) If <m_dwRelOperator> is WQL_TOK_IN_CONST_LIST or WQL_TOK_NOT_IN_CONST_LIST
  553. then <m_aConstSet> is an array of pointers to SWQLTypedConst structs representing
  554. the set of constants that the referenced column must intersect with.
  555. (5) If <m_dwRelOperator> is WQL_TOK_IN_SUBSELECT or WQL_TOK_NOT_IN_SUBSELECT
  556. then m_pSubSelect is a pointer to an embedded subselect tree in the form
  557. of a SWQLNode_Select struct, beginning the root of an entirely new select
  558. statement.
  559. */
  560. SWQLTypedExpr();
  561. ~SWQLTypedExpr() { Empty(); }
  562. void DebugDump();
  563. void Empty();
  564. };
  565. //***************************************************************************
  566. //
  567. // SWQLNode_RelExpr
  568. //
  569. // SWQLNode_RelExpr
  570. // / \
  571. // SWQLNode_RelExpr SWQLNode_RelExpr
  572. // or NULL or NULL
  573. //
  574. //***************************************************************************
  575. #define TYPE_SWQLNode_RelExpr (WQL_TOK_BASE + 13)
  576. struct SWQLNode_RelExpr : SWQLNode
  577. {
  578. DWORD m_dwExprType; // WQL_TOK_OR
  579. // WQL_TOK_AND
  580. // WQL_TOK_NOT
  581. // WQL_TOK_TYPED_EXPR
  582. SWQLTypedExpr *m_pTypedExpr;
  583. /*
  584. (1) If the <m_dwExprType> is WQL_TOK_AND or WQL_TOK_OR, then each of
  585. the two subnodes are themselves SWQLNode_RelExpr nodes and
  586. <m_pTypedExpr> points to NULL.
  587. (2) If <m_dwExprType> is WQL_TOK_NOT, then <m_pLeft> points to a
  588. SWQLNode_RelExpr containing the subclause to which to apply the NOT
  589. operation and <m_pRight> points to NULL.
  590. (3) If <m_dwExprType> is WQL_TOK_TYPED_EXPR, then <m_pLeft> and
  591. <m_pRight> both point to NULL, and <m_pTypedExpr> contains a typed
  592. relational subexpression.
  593. (4) Parentheses have been removed and are implied by the nesting.
  594. */
  595. SWQLNode_RelExpr() { m_dwNodeType = TYPE_SWQLNode_RelExpr; m_pTypedExpr = 0; m_dwExprType = 0; }
  596. ~SWQLNode_RelExpr() { delete m_pTypedExpr; }
  597. void DebugDump();
  598. };
  599. //***************************************************************************
  600. //
  601. // SWQLNode_WhereOptions
  602. //
  603. // SWQLNode_WhereOptions
  604. // / \
  605. // SWQLNode_GroupBy SWQLNode_OrderBy
  606. //
  607. //***************************************************************************
  608. #define TYPE_SWQLNode_WhereOptions (WQL_TOK_BASE + 14)
  609. struct SWQLNode_WhereOptions : SWQLNode
  610. {
  611. // left ptr is SWQLNode_GroupBy, or NULL if not used
  612. // right ptr is SWQLNode_OrderBy, or NULL if not used
  613. SWQLNode_WhereOptions() { m_dwNodeType = TYPE_SWQLNode_WhereOptions; }
  614. void DebugDump();
  615. };
  616. //***************************************************************************
  617. //
  618. // SWQLNode_GroupBy
  619. //
  620. // SWQLNode_GroupBy
  621. // / \
  622. // SWQLNode_ColumnList SWQLNode_Having
  623. // or NULL
  624. //
  625. //***************************************************************************
  626. #define TYPE_SWQLNode_GroupBy (WQL_TOK_BASE + 15)
  627. struct SWQLNode_GroupBy : SWQLNode
  628. {
  629. // left ptr is SWQLNode_ColumnList of columns to group by
  630. // right ptr is Having clause, if any
  631. SWQLNode_GroupBy() { m_dwNodeType = TYPE_SWQLNode_GroupBy; }
  632. void DebugDump();
  633. };
  634. //***************************************************************************
  635. //
  636. // SWQLNode_Having
  637. //
  638. // SWQLNode_Having
  639. // / \
  640. // SWQLNode_RelExpr NULL
  641. //
  642. //***************************************************************************
  643. #define TYPE_SWQLNode_Having (WQL_TOK_BASE + 16)
  644. struct SWQLNode_Having : SWQLNode
  645. {
  646. // left ptr is SQLNode_RelExpr pointing to HAVING expressions
  647. // right ptr is NULL
  648. SWQLNode_Having() { m_dwNodeType = TYPE_SWQLNode_Having; }
  649. void DebugDump();
  650. };
  651. //***************************************************************************
  652. //
  653. // SWQLNode_OrderBy
  654. //
  655. // SWQLNode_OrderBy
  656. // / \
  657. // SWQLNode_ColumnList NULL
  658. //
  659. //***************************************************************************
  660. #define TYPE_SWQLNode_OrderBy (WQL_TOK_BASE + 17)
  661. struct SWQLNode_OrderBy : SWQLNode
  662. {
  663. // left ptr is SWQLNode_ColumnList
  664. // right ptr is NULL
  665. SWQLNode_OrderBy() { m_dwNodeType = TYPE_SWQLNode_OrderBy; }
  666. void DebugDump();
  667. };
  668. //***************************************************************************
  669. //
  670. // SWQLNode_Datepart
  671. //
  672. // Contains a datepart call.
  673. //
  674. //***************************************************************************
  675. #define TYPE_SWQLNode_Datepart (WQL_TOK_BASE + 18)
  676. struct SWQLNode_Datepart : SWQLNode
  677. {
  678. int m_nDatepart; // One of WQL_TOK_YEAR, WQL_TOK_MONTH,
  679. // WQL_TOK_DAY, WQL_TOK_HOUR, WQL_TOK_MINUTE
  680. // WQL_TOK_SECOND
  681. SWQLColRef *m_pColRef; // The column to which DATEPART applies
  682. SWQLNode_Datepart() { m_dwNodeType = TYPE_SWQLNode_Datepart; m_nDatepart = 0; }
  683. ~SWQLNode_Datepart() { delete m_pColRef; }
  684. void DebugDump();
  685. };
  686. //***************************************************************************
  687. //
  688. // SWQLNode_Delete
  689. //
  690. // This is the root of a parse tree for delete.
  691. //
  692. // SWQLNode_Delete
  693. // / \
  694. // SWQLNode_TableRef vSWQLNode_WhereClause
  695. // / \
  696. // x x
  697. //
  698. //***************************************************************************
  699. #define TYPE_SWQLNode_Delete (WQL_TOK_BASE + 19)
  700. struct SWQLNode_Delete : SWQLNode
  701. {
  702. // Left Node is of type SWQLNode_TableRef
  703. // Right Node is of type SWQLNode_WhereClause
  704. SWQLNode_Delete() { m_dwNodeType = TYPE_SWQLNode_Delete; }
  705. ~SWQLNode_Delete();
  706. void DebugDump();
  707. };
  708. //***************************************************************************
  709. //
  710. // SWQLNode_Insert
  711. //
  712. // This is the root of an INSERT
  713. //
  714. // SWQLNode_Delete
  715. // / \
  716. // SWQLNode_TableRef SWQLNode_InsertValues
  717. // / \
  718. // x x
  719. //
  720. //***************************************************************************
  721. #define TYPE_SWQLNode_Insert (WQL_TOK_BASE + 20)
  722. struct SWQLNode_Insert : SWQLNode
  723. {
  724. SWQLNode_Insert() { m_dwNodeType = TYPE_SWQLNode_Insert; }
  725. ~SWQLNode_Insert();
  726. void DebugDump();
  727. };
  728. //***************************************************************************
  729. //
  730. // SWQLNode_Update
  731. //
  732. // This is the root of an INSERT
  733. //
  734. // SWQLNode_Update
  735. // / \
  736. // SWQLNode_SetClause SWQLNode_WhereClause
  737. //
  738. //***************************************************************************
  739. #define TYPE_SWQLNode_Update (WQL_TOK_BASE + 21)
  740. struct SWQLNode_Update : SWQLNode
  741. {
  742. SWQLNode_Update() { m_dwNodeType = TYPE_SWQLNode_Update; }
  743. ~SWQLNode_Update();
  744. void DebugDump();
  745. };
  746. //***************************************************************************
  747. //
  748. // SWQLNode_AssocQuery
  749. //
  750. // SWQLNode_AssocQuery
  751. // / \
  752. // NULL NULL
  753. //
  754. //***************************************************************************
  755. #define TYPE_SWQLNode_AssocQuery (WQL_TOK_BASE + 22)
  756. struct SWQLNode_AssocQuery : SWQLNode
  757. {
  758. CWbemAssocQueryInf *m_pAQInf;
  759. SWQLNode_AssocQuery() { m_pAQInf = 0; m_dwNodeType = TYPE_SWQLNode_AssocQuery; }
  760. ~SWQLNode_AssocQuery() { delete m_pAQInf; }
  761. void DebugDump();
  762. };
  763. #endif