Source code of Windows XP (NT5)
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.

244 lines
8.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2000.
  5. //
  6. // File: wqitem.hxx
  7. //
  8. // Contents: WEB Query cache class
  9. //
  10. // History: 96/Jan/3 DwightKr Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. const unsigned _int64 CWQueryItemSignature = 0x6c61726269476943; // CiGibral
  15. const unsigned MAX_QUERY_COLUMNS = 50;
  16. extern DBBINDING g_aDbBinding[ MAX_QUERY_COLUMNS ];
  17. class CHTXFile;
  18. class CWebCanonicalResultsOut;
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CWQueryItem
  22. //
  23. // Purpose: A single query item, including its associated IDQ & HTX files,
  24. // as well as the query results.
  25. //
  26. // History: 96/Jan/23 DwightKr Created
  27. //
  28. //----------------------------------------------------------------------------
  29. class CWQueryItem : public CDoubleLink
  30. {
  31. public:
  32. CWQueryItem(CIDQFile & idqFile,
  33. CHTXFile & htxFile,
  34. XPtrST<WCHAR> & wcsColumns,
  35. XPtr<CDbColumns> & dbColumns,
  36. CDynArray<WCHAR> & awcsColumns,
  37. ULONG ulSequenceNumber,
  38. LONG lNextRecordNumber,
  39. CSecurityIdentity securityIdentity );
  40. ~CWQueryItem();
  41. void AddRef()
  42. {
  43. long x = InterlockedIncrement( (LONG *) &_refCount );
  44. // underflow check
  45. Win4Assert( 0 != x );
  46. }
  47. void Release()
  48. {
  49. long x = InterlockedDecrement( (LONG *) &_refCount );
  50. // underflow check
  51. Win4Assert( 0xffffffff != x );
  52. }
  53. ULONG LokGetRefCount() const { return _refCount; }
  54. time_t LokGetLastAccessTime() const { return _lastAccessTime; }
  55. ULONG GetSequenceNumber() const { return _ulSequenceNumber; }
  56. LONG GetNextRecordNumber() const { return _lNextRecordNumber; }
  57. void SetNextRecordNumber(LONG lNextRecordNumber)
  58. {
  59. Win4Assert( IsSequential() );
  60. _lNextRecordNumber = lNextRecordNumber;
  61. }
  62. void ExecuteQuery( CVariableSet & variableSet,
  63. COutputFormat & outputFormat );
  64. BOOL LokIsCachedDataValid()
  65. {
  66. return _idqFile.IsCachedDataValid() &&
  67. _htxFile.IsCachedDataValid();
  68. }
  69. void OutputQueryResults( CVariableSet & variableSet,
  70. COutputFormat & outputFormat,
  71. CVirtualString & vString );
  72. void OutputQueryResults( CVariableSet & variableSet,
  73. COutputFormat & outputFormat,
  74. CWebCanonicalResultsOut & output );
  75. WCHAR const * GetRestriction() const { return _wcsRestriction; }
  76. WCHAR const * GetScope() const { return _wcsScope; }
  77. WCHAR const * GetSort() const { return _wcsSort; }
  78. WCHAR const * GetIDQFileName() const { return _idqFile.GetIDQFileName(); }
  79. WCHAR const * GetTemplate() const { return _htxFile.GetVirtualName(); }
  80. WCHAR const * GetCatalog() const { return _wcsCatalog; }
  81. WCHAR const * GetColumns() const { return _wcsColumns; }
  82. SYSTEMTIME & GetQueryTime() { return _queryTime; }
  83. WCHAR const * GetQueryTimeZone() const { return _wcsQueryTimeZone; }
  84. WCHAR const * GetCiFlags() const { return _wcsCiFlags; }
  85. WCHAR const * GetForceUseCI() const { return _wcsForceUseCI; }
  86. WCHAR const * GetDeferTrimming() const { return _wcsDeferTrimming; }
  87. BOOL IsSequential() const { return _htxFile.IsSequential(); }
  88. unsigned _int64 GetSignature() const { return _signature; }
  89. CSecurityIdentity & GetSecurityIdentity() { return _securityIdentity; }
  90. //BOOL IsQueryUpToDate();
  91. void UpdateQueryStatus( CVariableSet & variableSet );
  92. BOOL IsZombie() const { return _fIsZombie; }
  93. void Zombify() { _fIsZombie = TRUE; }
  94. BOOL IsInCache() const { return _fInCache; }
  95. void InCache() { _fInCache = TRUE; }
  96. BOOL CanCache() const { return _fCanCache; }
  97. BOOL IsQueryDone();
  98. ULONG GetReplaceableParameterCount() const
  99. {
  100. return _idqFile.GetReplaceableParameterCount();
  101. }
  102. BOOL IsCanonicalOutput() const
  103. {
  104. return _idqFile.IsCanonicalOutput();
  105. }
  106. CIDQFile & GetIDQFile() const { return _idqFile; }
  107. CHTXFile & GetHTXFile() const { return _htxFile; }
  108. LCID GetLocale() const { return _locale; }
  109. LONG GetMaxRecordsInResultSet() const { return _lMaxRecordsInResultSet; }
  110. LONG GetFirstRowsInResultSet() const { return _lFirstRowsInResultSet; }
  111. #if (DBG == 1)
  112. void LokDump( CVirtualString & string,
  113. CVariableSet * pVariableSet = 0,
  114. COutputFormat * pOutputFormat = 0 );
  115. #endif
  116. private:
  117. CBaseQueryResultsIter * GetQueryResultsIterator( COutputFormat & outputFormat );
  118. void ConvertValueToString( COutputColumn & column,
  119. DBTYPE dbType,
  120. NUMBERFMT * pNumberFormat,
  121. CVirtualString & string );
  122. unsigned _int64 _signature; // Signature to ID this memory block
  123. ULONG _ulSequenceNumber; // Unique sequence number
  124. ULONG _refCount; // Ref count
  125. time_t _lastAccessTime; // Last time this query accessed
  126. BOOL _fIsZombie; // Is this a zombie query
  127. BOOL _fInCache; // Is this item in the cache
  128. BOOL _fCanCache; // TRUE for non-admin queries
  129. LCID _locale; // Locale used for this query
  130. WCHAR * _wcsRestriction; // Restriction string
  131. WCHAR * _wcsDialect; // Restriction version
  132. WCHAR * _wcsSort; // Sort string
  133. WCHAR * _wcsScope; // Query scope
  134. WCHAR * _wcsCatalog; // Catalog as in CiCatalog
  135. WCHAR * _wcsColumns; // Output columns
  136. WCHAR * _wcsCiFlags; // CI Flags
  137. WCHAR * _wcsForceUseCI; // ForceUseCI flag
  138. WCHAR * _wcsDeferTrimming; // DeferTrimming flag
  139. WCHAR * _wcsQueryTimeZone; // Timezone of the query
  140. SYSTEMTIME _queryTime; // Time query executed
  141. CDbColumns * _pDbColumns; // Output column specification
  142. CDynArray<WCHAR> _awcsColumns; // Parsed column names
  143. IRowset * _pIRowset; // Cached query results
  144. IAccessor * _pIAccessor; // Accessor to query results
  145. IRowsetQueryStatus *_pIRowsetStatus; // Interface to determine if done
  146. ICommand * _pICommand; // Main query ICommand
  147. HACCESSOR _hAccessor; // Handle to accessor
  148. LONG _lMaxRecordsInResultSet; // # items to examine
  149. LONG _lFirstRowsInResultSet;
  150. LONG _lNextRecordNumber; // Next available rec # in query
  151. ULONG _cFilteredDocuments; // # documents filtered in the catalog
  152. ULONG _ulDialect; // wtoi(_wcsDialect)
  153. CIDQFile & _idqFile; // A parsed IDQ file
  154. CHTXFile & _htxFile; // A parsed HTX file
  155. CSecurityIdentity _securityIdentity; // Security ID of this query
  156. };
  157. //+---------------------------------------------------------------------------
  158. //
  159. // Class: CWPendingQueryItem
  160. //
  161. // Purpose: A single pending query item.
  162. //
  163. // History: 96/Mar/01 DwightKr Created
  164. //
  165. //----------------------------------------------------------------------------
  166. class CWPendingQueryItem
  167. {
  168. public:
  169. CWPendingQueryItem( XPtr<CWQueryItem> & queryItem,
  170. XPtr<COutputFormat> & outputFormat,
  171. XPtr<CVariableSet> & variableSet );
  172. ~CWPendingQueryItem();
  173. BOOL IsQueryDone()
  174. {
  175. Win4Assert( 0 != _pQueryItem );
  176. return _pQueryItem->IsQueryDone();
  177. }
  178. CWQueryItem * AcquirePendingQueryItem()
  179. {
  180. Win4Assert( 0 != _pQueryItem );
  181. CWQueryItem *pItem = _pQueryItem;
  182. _pQueryItem = 0;
  183. return pItem;
  184. }
  185. CWQueryItem * GetPendingQueryItem() const { return _pQueryItem; }
  186. COutputFormat & GetOutputFormat() { return *_pOutputFormat; }
  187. CVariableSet & GetVariableSet() { return *_pVariableSet; }
  188. #if (DBG == 1)
  189. void LokDump( CVirtualString & string );
  190. #endif
  191. private:
  192. CWQueryItem * _pQueryItem; // The corresponding query
  193. COutputFormat * _pOutputFormat; // String format of #'s & dates
  194. CVariableSet * _pVariableSet; // List of browser variables
  195. };