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.

5178 lines
201 KiB

  1. #ifndef lint
  2. static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
  3. #endif
  4. #define YYBYACC 1
  5. #define YYMAJOR 1
  6. #define YYMINOR 9
  7. #define yyclearin (yychar=(-1))
  8. #define yyerrok (yyerrflag=0)
  9. #define YYRECOVERING (yyerrflag!=0)
  10. #define YYPREFIX "yy"
  11. //--------------------------------------------------------------------
  12. // Microsoft Monarch
  13. //
  14. // Copyright (c) Microsoft Corporation, 1997 - 1999.
  15. //
  16. // @doc OPTIONAL EXTRACTION CODES
  17. //
  18. // @module MS-sql.y |
  19. // Monarch SQL YACC Script
  20. //
  21. // @devnote none
  22. //
  23. // @rev 0 | 04-Feb-97 | v-charca | Created
  24. //
  25. /* 3.4 Object identifier for Database Language SQL */
  26. #pragma hdrstop
  27. #pragma optimize("g", off)
  28. #include "msidxtr.h"
  29. EXTERN_C const IID IID_IColumnMapperCreator;
  30. #define VAL_AND_CCH_MINUS_NULL(p1) (p1), ((sizeof(p1) / sizeof(*(p1))) - 1)
  31. #ifdef YYDEBUG
  32. #define YYTRACE(a,b,c) wprintf(L"** %s[%s%s] ** \n", a, b, c);
  33. #else
  34. #define YYTRACE(a,b,c)
  35. #endif
  36. #ifdef DEBUG
  37. #define AssertReq(x) Assert(x != NULL)
  38. #else
  39. #define AssertReq(x)
  40. #endif
  41. #define DEFAULTWEIGHT 1000
  42. typedef struct tagDBTYPENAMETABLE
  43. {
  44. LPWSTR pwszDBTypeName;
  45. DBTYPE dbType;
  46. } DBTYPENAMETABLE;
  47. // J F M A M J J A S O N D
  48. const short LeapDays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  49. const short Days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  50. #define IsLeapYear(yrs) ( \
  51. (((yrs) % 400 == 0) || \
  52. ((yrs) % 100 != 0) && ((yrs) % 4 == 0)) ? \
  53. TRUE \
  54. : \
  55. FALSE \
  56. )
  57. #define DaysInMonth(YEAR,MONTH) ( \
  58. IsLeapYear(YEAR) ? \
  59. LeapDays[(MONTH)] : \
  60. Days[(MONTH)] \
  61. )
  62. //-----------------------------------------------------------------------------
  63. // @func GetDBTypeFromStr
  64. //
  65. // This function takes a TypeName as input, and returns the DBTYPE of the string
  66. //
  67. // @rdesc DBTYPE
  68. //-----------------------------------------------------------------------------
  69. DBTYPE GetDBTypeFromStr(
  70. LPWSTR pwszDBTypeName ) // @parm IN
  71. {
  72. DBTYPE dbType = DBTYPE_EMPTY;
  73. if ( 9 <= wcslen(pwszDBTypeName) )
  74. switch ( pwszDBTypeName[7] )
  75. {
  76. case L'U':
  77. case L'u':
  78. if (10 == wcslen(pwszDBTypeName))
  79. switch ( pwszDBTypeName[9])
  80. {
  81. case L'1':
  82. if (0 == _wcsicmp(L"DBTYPE_UI1", pwszDBTypeName))
  83. dbType = DBTYPE_UI1;
  84. break;
  85. case L'2':
  86. if (0 == _wcsicmp(L"DBTYPE_UI2", pwszDBTypeName))
  87. dbType = DBTYPE_UI2;
  88. break;
  89. case L'4':
  90. if (0 == _wcsicmp(L"DBTYPE_UI4", pwszDBTypeName))
  91. dbType = DBTYPE_UI4;
  92. break;
  93. case L'8':
  94. if (0 == _wcsicmp(L"DBTYPE_UI8", pwszDBTypeName))
  95. dbType = DBTYPE_UI8;
  96. break;
  97. default:
  98. break;
  99. }
  100. break;
  101. case L'I':
  102. case L'i':
  103. switch ( pwszDBTypeName[8] )
  104. {
  105. case L'1':
  106. if ( 0 == _wcsicmp(L"DBTYPE_I1", pwszDBTypeName) )
  107. dbType = DBTYPE_I1;
  108. break;
  109. case L'2':
  110. if ( 0 == _wcsicmp(L"DBTYPE_I2", pwszDBTypeName) )
  111. dbType = DBTYPE_I2;
  112. break;
  113. case L'4':
  114. if ( 0 == _wcsicmp(L"DBTYPE_I4", pwszDBTypeName) )
  115. dbType = DBTYPE_I4;
  116. break;
  117. case L'8':
  118. if ( 0 == _wcsicmp(L"DBTYPE_I8", pwszDBTypeName) )
  119. dbType = DBTYPE_I8;
  120. break;
  121. default:
  122. break;
  123. }
  124. break;
  125. case L'R':
  126. case L'r':
  127. switch ( pwszDBTypeName[8] )
  128. {
  129. case L'4':
  130. if ( 0 == _wcsicmp(L"DBTYPE_R4", pwszDBTypeName) )
  131. dbType = DBTYPE_R4;
  132. break;
  133. case L'8':
  134. if (0 == _wcsicmp(L"DBTYPE_R8", pwszDBTypeName))
  135. dbType = DBTYPE_R8;
  136. break;
  137. default:
  138. break;
  139. }
  140. break;
  141. case L'B':
  142. case L'b':
  143. if ( 10 <= wcslen(pwszDBTypeName) )
  144. switch ( pwszDBTypeName[8] )
  145. {
  146. case L'S':
  147. case L's':
  148. if ( 0 == _wcsicmp(L"DBTYPE_BSTR", pwszDBTypeName) )
  149. dbType = DBTYPE_BSTR;
  150. break;
  151. case L'O':
  152. case L'o':
  153. if ( 0 == _wcsicmp(L"DBTYPE_BOOL", pwszDBTypeName) )
  154. dbType = DBTYPE_BOOL;
  155. break;
  156. case L'Y':
  157. case L'y':
  158. if ( 0 == _wcsicmp(L"DBTYPE_BYREF", pwszDBTypeName) )
  159. dbType = DBTYPE_BYREF;
  160. break;
  161. default:
  162. break;
  163. }
  164. break;
  165. case L'E':
  166. case L'e':
  167. if ( 0 == _wcsicmp(L"DBTYPE_EMPTY", pwszDBTypeName) )
  168. dbType = DBTYPE_EMPTY;
  169. break;
  170. case L'N':
  171. case L'n':
  172. if ( 0 == _wcsicmp(L"DBTYPE_NULL", pwszDBTypeName) )
  173. dbType = DBTYPE_NULL;
  174. break;
  175. case L'C':
  176. case L'c':
  177. if ( 0 == _wcsicmp(L"DBTYPE_CY", pwszDBTypeName) )
  178. dbType = DBTYPE_CY;
  179. break;
  180. case L'D':
  181. case L'd':
  182. if ( 0 == _wcsicmp(L"DBTYPE_DATE", pwszDBTypeName) )
  183. dbType = DBTYPE_DATE;
  184. break;
  185. case L'G':
  186. case L'g':
  187. if ( 0 == _wcsicmp(L"DBTYPE_GUID", pwszDBTypeName) )
  188. dbType = DBTYPE_GUID;
  189. break;
  190. case L'S':
  191. case L's':
  192. if ( 0 == _wcsicmp(L"DBTYPE_STR", pwszDBTypeName) )
  193. dbType = DBTYPE_STR;
  194. break;
  195. case L'W':
  196. case L'w':
  197. if ( 0 == _wcsicmp(L"DBTYPE_WSTR", pwszDBTypeName) )
  198. dbType = DBTYPE_WSTR;
  199. break;
  200. case L'T':
  201. case L't':
  202. if ( 0 == _wcsicmp(L"VT_FILETIME", pwszDBTypeName) )
  203. dbType = VT_FILETIME;
  204. break;
  205. case L'V':
  206. case L'v':
  207. if ( 0 == _wcsicmp(L"DBTYPE_VECTOR", pwszDBTypeName) )
  208. dbType = DBTYPE_VECTOR;
  209. break;
  210. default:
  211. break;
  212. }
  213. return dbType;
  214. }
  215. const DBTYPENAMETABLE dbTypeNameTable[] =
  216. {
  217. {L"DBTYPE_EMPTY", DBTYPE_EMPTY},
  218. {L"DBTYPE_NULL", DBTYPE_NULL},
  219. {L"DBTYPE_I2", DBTYPE_I2},
  220. {L"DBTYPE_I4", DBTYPE_I4},
  221. {L"DBTYPE_R4", DBTYPE_R4},
  222. {L"DBTYPE_R8", DBTYPE_R8},
  223. {L"DBTYPE_CY", DBTYPE_CY},
  224. {L"DBTYPE_DATE", DBTYPE_DATE},
  225. {L"DBTYPE_BSTR", DBTYPE_BSTR},
  226. {L"DBTYPE_BOOL", DBTYPE_BOOL},
  227. {L"DBTYPE_UI1", DBTYPE_UI1},
  228. {L"DBTYPE_I1", DBTYPE_I1},
  229. {L"DBTYPE_UI2", DBTYPE_UI2},
  230. {L"DBTYPE_UI4", DBTYPE_UI4},
  231. {L"DBTYPE_I8", DBTYPE_I8},
  232. {L"DBTYPE_UI8", DBTYPE_UI8},
  233. {L"DBTYPE_GUID", DBTYPE_GUID},
  234. {L"DBTYPE_STR", DBTYPE_STR},
  235. {L"DBTYPE_WSTR", DBTYPE_WSTR},
  236. {L"DBTYPE_BYREF", DBTYPE_BYREF},
  237. {L"VT_FILETIME", VT_FILETIME},
  238. {L"DBTYPE_VECTOR", DBTYPE_VECTOR}
  239. };
  240. //-----------------------------------------------------------------------------
  241. // @func PctCreateContentNode
  242. //
  243. // This function takes a content string as input and creates a content node
  244. // with the specified generate method and weight.
  245. //
  246. // @rdesc DBCOMMANDTREE*
  247. //-----------------------------------------------------------------------------
  248. DBCOMMANDTREE* PctCreateContentNode(
  249. LPWSTR pwszContent, // @parm IN | content for the node
  250. DWORD dwGenerateMethod,//@parm IN | generate method
  251. LONG lWeight, // @parm IN | weight
  252. LCID lcid, // @parm IN | locale identifier
  253. DBCOMMANDTREE* pctFirstChild ) // @parm IN | node to link to new node
  254. {
  255. DBCOMMANDTREE* pct = PctCreateNode( DBOP_content, DBVALUEKIND_CONTENT, pctFirstChild, NULL );
  256. if ( 0 != pct )
  257. {
  258. pct->value.pdbcntntValue->pwszPhrase = CoTaskStrDup( pwszContent );
  259. if (pct->value.pdbcntntValue->pwszPhrase)
  260. {
  261. pct->value.pdbcntntValue->dwGenerateMethod = dwGenerateMethod;
  262. pct->value.pdbcntntValue->lWeight = lWeight;
  263. pct->value.pdbcntntValue->lcid = lcid;
  264. }
  265. else
  266. {
  267. DeleteDBQT( pct );
  268. pct = 0;
  269. }
  270. }
  271. return pct;
  272. }
  273. //-----------------------------------------------------------------------------
  274. // @func PctCreateBooleanNode
  275. //
  276. // This function creates a content node with the specified children and weight.
  277. //
  278. // @rdesc DBCOMMANDTREE*
  279. //-----------------------------------------------------------------------------
  280. DBCOMMANDTREE* PctCreateBooleanNode(
  281. DBCOMMANDOP op, // @parm IN | op tag for new node
  282. LONG lWeight, // @parm IN | Weight of the boolean node
  283. DBCOMMANDTREE* pctChild, // @parm IN | child of boolean node
  284. DBCOMMANDTREE* pctSibling )// @parm IN | second child of boolean node
  285. {
  286. DBCOMMANDTREE* pct = PctCreateNode( op, DBVALUEKIND_I4, pctChild, pctSibling, NULL );
  287. if ( 0 != pct )
  288. pct->value.lValue = lWeight;
  289. return pct;
  290. }
  291. //-----------------------------------------------------------------------------
  292. // @func PctCreateNotNode
  293. //
  294. // This function creates a not node with the specified child and weight.
  295. //
  296. // @rdesc DBCOMMANDTREE*
  297. //-----------------------------------------------------------------------------
  298. DBCOMMANDTREE* PctCreateNotNode(
  299. LONG lWeight, // @parm IN | Weight of the boolean node
  300. DBCOMMANDTREE* pctChild ) // @parm IN | child of NOT node
  301. {
  302. DBCOMMANDTREE* pct = PctCreateNode( DBOP_not, DBVALUEKIND_I4, pctChild, NULL );
  303. if ( 0 != pct )
  304. pct->value.lValue = lWeight;
  305. return pct;
  306. }
  307. //-----------------------------------------------------------------------------
  308. // @func PctCreateRelationalNode
  309. //
  310. // This function creates a relational node with the specied op and weight.
  311. //
  312. // @rdesc DBCOMMANDTREE*
  313. //-----------------------------------------------------------------------------
  314. DBCOMMANDTREE* PctCreateRelationalNode(
  315. DBCOMMANDOP op, // @parm IN | op tag for new node
  316. LONG lWeight ) // @parm IN | Weight of the relational node
  317. {
  318. DBCOMMANDTREE* pct = PctCreateNode(op, DBVALUEKIND_I4, NULL);
  319. if ( 0 != pct)
  320. pct->value.lValue = lWeight;
  321. return pct;
  322. }
  323. //-----------------------------------------------------------------------------
  324. // @func SetLWeight
  325. //
  326. // This function sets the lWeight value for vector searches
  327. //
  328. //-----------------------------------------------------------------------------
  329. void SetLWeight(
  330. DBCOMMANDTREE* pct, // @parm IN | node or subtree to set
  331. LONG lWeight ) // @parm IN | weight value for node(s)
  332. {
  333. if ( DBOP_content == pct->op )
  334. pct->value.pdbcntntValue->lWeight = lWeight;
  335. else
  336. {
  337. AssertReq( pct->pctFirstChild );
  338. AssertReq( pct->pctFirstChild->pctNextSibling );
  339. SetLWeight(pct->pctFirstChild, lWeight);
  340. DBCOMMANDTREE* pctNext = pct->pctFirstChild->pctNextSibling;
  341. while ( pctNext )
  342. {
  343. // A content_proximity node can have lots of siblings
  344. SetLWeight( pctNext, lWeight );
  345. pctNext = pctNext->pctNextSibling;
  346. }
  347. }
  348. }
  349. //-----------------------------------------------------------------------------
  350. // @func GetLWeight
  351. //
  352. // This function gets the lWeight value for vector searches
  353. //-----------------------------------------------------------------------------
  354. LONG GetLWeight(
  355. DBCOMMANDTREE* pct ) // @parm IN | node or subtree to set
  356. {
  357. if ( DBOP_content == pct->op )
  358. return pct->value.pdbcntntValue->lWeight;
  359. else
  360. {
  361. AssertReq( pct->pctFirstChild );
  362. return GetLWeight( pct->pctFirstChild );
  363. }
  364. }
  365. //-----------------------------------------------------------------------------
  366. // @func PctBuiltInProperty
  367. //
  368. // This function takes a column name string as input and creates a column_name
  369. // node containing the appropriate GUID information if the column_name is a
  370. // built-in property
  371. //
  372. // @rdesc DBCOMMANDTREE*
  373. //-----------------------------------------------------------------------------
  374. DBCOMMANDTREE* PctBuiltInProperty(
  375. LPWSTR pwszColumnName, // @parm IN | name of column
  376. CImpIParserSession* pIPSession, // @parm IN | Parser Session
  377. CImpIParserTreeProperties* pIPTProps ) // @parm IN | Parser Properties
  378. {
  379. DBCOMMANDTREE* pct = 0;
  380. DBID *pDBID = 0;
  381. DBTYPE uwType = 0;
  382. UINT uiWidth = 0;
  383. BOOL fOk = 0;
  384. ICiPropertyList* pIPropList = 0;
  385. IColumnMapper* pIColumnMapper = pIPSession->GetColumnMapperPtr();
  386. if ( 0 != pIColumnMapper )
  387. {
  388. // we were able to use the IColumnMapper interface
  389. HRESULT hr = S_OK;
  390. // Olympus kludge
  391. if ( 0 == _wcsicmp(pwszColumnName, L"URL") )
  392. hr = pIColumnMapper->GetPropInfoFromName( L"VPATH", &pDBID, &uwType, &uiWidth );
  393. else
  394. hr = pIColumnMapper->GetPropInfoFromName( pwszColumnName, &pDBID, &uwType, &uiWidth );
  395. if ( SUCCEEDED(hr) )
  396. fOk = TRUE;
  397. else
  398. fOk = FALSE;
  399. }
  400. else
  401. fOk = FALSE; // @TODO: this should generate some sort of error message.
  402. if ( fOk ) // this is a built-in (well known) property
  403. {
  404. pIPTProps->SetDBType( uwType ); // remember the type of this
  405. pct = PctCreateNode( DBOP_column_name, DBVALUEKIND_ID, NULL );
  406. if ( 0 != pct )
  407. {
  408. pct->value.pdbidValue->eKind = pDBID->eKind;
  409. pct->value.pdbidValue->uGuid.guid = pDBID->uGuid.guid;
  410. switch ( pct->value.pdbidValue->eKind )
  411. {
  412. case DBKIND_NAME:
  413. case DBKIND_GUID_NAME:
  414. // need to create a new string
  415. pct->value.pdbidValue->uName.pwszName = CoTaskStrDup(pDBID->uName.pwszName);
  416. break;
  417. case DBKIND_GUID:
  418. case DBKIND_GUID_PROPID:
  419. pct->value.pdbidValue->uName.pwszName = pDBID->uName.pwszName;
  420. break;
  421. case DBKIND_PGUID_NAME:
  422. // need to create a new string
  423. pct->value.pdbidValue->uName.pwszName = CoTaskStrDup(pDBID->uName.pwszName);
  424. // need to allocate and copy guid
  425. pct->value.pdbidValue->uGuid.pguid = (GUID*)CoTaskMemAlloc(sizeof(GUID));
  426. *pct->value.pdbidValue->uGuid.pguid = *pDBID->uGuid.pguid;
  427. break;
  428. case DBKIND_PGUID_PROPID:
  429. // need to allocate and copy guid
  430. pct->value.pdbidValue->uGuid.pguid = (GUID*)CoTaskMemAlloc(sizeof(GUID));
  431. *pct->value.pdbidValue->uGuid.pguid = *pDBID->uGuid.pguid;
  432. break;
  433. default:
  434. Assert(0);
  435. }
  436. }
  437. if ( 0 != pIPropList )
  438. pIPropList->Release();
  439. }
  440. return pct;
  441. }
  442. //-----------------------------------------------------------------------------
  443. // @func PctMkColNodeFromStr
  444. //
  445. // This function takes a column name string as input and creates a column_name
  446. // node containing the appropriate GUID information.
  447. //
  448. // @rdesc DBCOMMANDTREE*
  449. //-----------------------------------------------------------------------------
  450. DBCOMMANDTREE* PctMkColNodeFromStr(
  451. LPWSTR pwszColumnName, // @parm IN | name of column
  452. CImpIParserSession* pIPSession, // @parm IN | Parser Session
  453. CImpIParserTreeProperties* pIPTProps ) // @parm IN | Parser Properties
  454. {
  455. DBCOMMANDTREE* pct = 0;
  456. pct = PctBuiltInProperty( pwszColumnName, pIPSession, pIPTProps );
  457. if ( 0 == pct )
  458. { // this may be a user defined property, or is undefined
  459. DBTYPE dbType = 0;
  460. HRESULT hr = pIPSession->m_pCPropertyList->LookUpPropertyName( pwszColumnName, &pct, &dbType );
  461. if ( E_OUTOFMEMORY == hr )
  462. pIPTProps->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  463. else if ( FAILED(hr) )
  464. {
  465. pIPTProps->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_COLUMN_NOT_DEFINED );
  466. pIPTProps->SetErrorToken( pwszColumnName );
  467. }
  468. else
  469. {
  470. AssertReq( 0 != pct );
  471. pIPTProps->SetDBType( dbType );
  472. }
  473. }
  474. return pct;
  475. }
  476. /* ************************************************************************************************ */
  477. /* ************************************************************************************************ */
  478. /* ************************************************************************************************ */
  479. #define _OR 257
  480. #define _AND 258
  481. #define _NOT 259
  482. #define _UMINUS 260
  483. #define mHighest 261
  484. #define _ALL 262
  485. #define _ANY 263
  486. #define _ARRAY 264
  487. #define _AS 265
  488. #define _ASC 266
  489. #define _CAST 267
  490. #define _COERCE 268
  491. #define _CONTAINS 269
  492. #define _CONTENTS 270
  493. #define _CREATE 271
  494. #define _DEEP_TRAVERSAL 272
  495. #define _DESC 273
  496. #define _DOT 274
  497. #define _DOTDOT 275
  498. #define _DOTDOT_SCOPE 276
  499. #define _DOTDOTDOT 277
  500. #define _DOTDOTDOT_SCOPE 278
  501. #define _DROP 279
  502. #define _EXCLUDE_SEARCH_TRAVERSAL 280
  503. #define _FALSE 281
  504. #define _FREETEXT 282
  505. #define _FROM 283
  506. #define _IS 284
  507. #define _ISABOUT 285
  508. #define _IS_NOT 286
  509. #define _LIKE 287
  510. #define _MATCHES 288
  511. #define _NEAR 289
  512. #define _NOT_LIKE 290
  513. #define _NULL 291
  514. #define _OF 292
  515. #define _ORDER_BY 293
  516. #define _PASSTHROUGH 294
  517. #define _PROPERTYNAME 295
  518. #define _PROPID 296
  519. #define _RANKMETHOD 297
  520. #define _SELECT 298
  521. #define _SET 299
  522. #define _SCOPE 300
  523. #define _SHALLOW_TRAVERSAL 301
  524. #define _FORMSOF 302
  525. #define _SOME 303
  526. #define _TABLE 304
  527. #define _TRUE 305
  528. #define _TYPE 306
  529. #define _UNION 307
  530. #define _UNKNOWN 308
  531. #define _URL 309
  532. #define _VIEW 310
  533. #define _WHERE 311
  534. #define _WEIGHT 312
  535. #define _GE 313
  536. #define _LE 314
  537. #define _NE 315
  538. #define _CONST 316
  539. #define _ID 317
  540. #define _TEMPVIEW 318
  541. #define _INTNUM 319
  542. #define _REALNUM 320
  543. #define _SCALAR_FUNCTION_REF 321
  544. #define _STRING 322
  545. #define _DATE 323
  546. #define _PREFIX_STRING 324
  547. #define _DELIMITED_ID 325
  548. #define YYERRCODE 256
  549. short yylhs[] = { -1,
  550. 0, 0, 0, 2, 4, 4, 1, 1, 5, 5,
  551. 5, 6, 6, 10, 10, 10, 10, 10, 13, 14,
  552. 11, 11, 12, 12, 15, 16, 3, 17, 19, 19,
  553. 20, 20, 23, 23, 24, 24, 24, 21, 21, 25,
  554. 27, 27, 27, 29, 30, 30, 30, 33, 34, 32,
  555. 32, 35, 35, 36, 36, 37, 37, 37, 38, 38,
  556. 39, 28, 28, 26, 40, 40, 40, 40, 40, 40,
  557. 40, 40, 31, 41, 41, 42, 22, 22, 43, 43,
  558. 45, 45, 45, 45, 45, 45, 45, 46, 53, 53,
  559. 55, 55, 55, 54, 54, 54, 54, 54, 54, 47,
  560. 57, 57, 61, 58, 60, 60, 62, 62, 64, 64,
  561. 66, 69, 66, 68, 68, 68, 68, 68, 63, 63,
  562. 65, 65, 67, 67, 70, 71, 72, 76, 76, 77,
  563. 75, 75, 78, 78, 78, 73, 79, 80, 80, 74,
  564. 81, 81, 82, 82, 83, 83, 83, 83, 84, 59,
  565. 59, 48, 49, 49, 85, 50, 86, 51, 89, 90,
  566. 90, 87, 87, 87, 87, 87, 87, 87, 87, 87,
  567. 87, 87, 87, 87, 87, 87, 87, 87, 87, 88,
  568. 91, 93, 92, 92, 94, 94, 95, 52, 52, 44,
  569. 44, 96, 96, 98, 98, 97, 99, 101, 100, 100,
  570. 100, 100, 100, 100, 100, 103, 102, 102, 104, 105,
  571. 105, 106, 108, 108, 108, 107, 107, 18, 18, 9,
  572. 9, 9, 109, 109, 114, 115, 115, 56, 56, 117,
  573. 113, 116, 112, 110, 118, 118, 111, 7, 8,
  574. };
  575. short yylen[] = { 2,
  576. 1, 2, 1, 2, 0, 1, 3, 2, 1, 1,
  577. 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
  578. 8, 3, 1, 1, 1, 1, 2, 5, 0, 1,
  579. 1, 1, 3, 1, 1, 3, 1, 1, 1, 3,
  580. 1, 1, 1, 4, 5, 7, 5, 1, 1, 0,
  581. 1, 3, 1, 4, 6, 0, 2, 2, 3, 1,
  582. 1, 0, 2, 2, 1, 1, 3, 3, 5, 5,
  583. 3, 3, 3, 4, 4, 2, 0, 1, 2, 5,
  584. 1, 1, 1, 1, 1, 1, 1, 3, 1, 6,
  585. 1, 3, 1, 1, 1, 1, 1, 1, 1, 8,
  586. 0, 2, 0, 2, 1, 3, 1, 3, 1, 2,
  587. 1, 0, 4, 1, 1, 1, 1, 1, 1, 1,
  588. 1, 1, 1, 1, 1, 1, 2, 2, 1, 2,
  589. 1, 1, 1, 3, 1, 6, 1, 3, 1, 4,
  590. 3, 1, 5, 1, 1, 1, 1, 1, 1, 0,
  591. 2, 6, 3, 3, 1, 7, 1, 3, 1, 1,
  592. 1, 1, 2, 2, 1, 2, 2, 1, 2, 2,
  593. 1, 2, 2, 1, 2, 2, 1, 2, 2, 4,
  594. 1, 1, 0, 1, 3, 1, 1, 3, 3, 1,
  595. 3, 1, 3, 1, 2, 1, 1, 1, 1, 3,
  596. 3, 3, 3, 3, 3, 0, 2, 3, 2, 3,
  597. 1, 2, 0, 1, 1, 1, 1, 0, 1, 1,
  598. 1, 1, 8, 8, 1, 0, 2, 1, 3, 1,
  599. 1, 1, 1, 3, 2, 1, 3, 7, 3,
  600. };
  601. short yydefred[] = { 0,
  602. 0, 0, 0, 0, 0, 0, 3, 0, 0, 9,
  603. 10, 11, 0, 220, 221, 222, 0, 0, 30, 0,
  604. 0, 0, 0, 2, 0, 6, 4, 13, 8, 0,
  605. 27, 219, 25, 65, 0, 0, 0, 0, 239, 32,
  606. 37, 0, 0, 0, 0, 34, 233, 0, 0, 234,
  607. 237, 7, 93, 20, 217, 0, 0, 216, 0, 211,
  608. 0, 0, 0, 0, 0, 0, 0, 0, 38, 39,
  609. 0, 0, 235, 0, 0, 214, 215, 212, 49, 0,
  610. 72, 71, 67, 68, 0, 36, 0, 0, 0, 41,
  611. 42, 43, 0, 0, 64, 0, 28, 78, 33, 19,
  612. 232, 231, 0, 0, 92, 210, 0, 0, 0, 0,
  613. 0, 0, 0, 40, 0, 0, 0, 198, 0, 0,
  614. 0, 0, 192, 194, 0, 0, 0, 0, 0, 69,
  615. 70, 238, 0, 76, 0, 0, 73, 0, 0, 0,
  616. 0, 0, 53, 26, 63, 0, 0, 0, 0, 0,
  617. 196, 0, 197, 0, 195, 0, 0, 0, 0, 0,
  618. 0, 207, 81, 82, 83, 84, 85, 86, 87, 0,
  619. 0, 225, 0, 0, 0, 0, 0, 0, 0, 0,
  620. 44, 0, 0, 0, 0, 208, 0, 0, 193, 201,
  621. 200, 202, 204, 203, 205, 0, 0, 0, 0, 0,
  622. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  623. 0, 0, 223, 224, 0, 74, 75, 57, 58, 0,
  624. 61, 0, 60, 52, 0, 45, 47, 80, 0, 0,
  625. 0, 0, 0, 159, 161, 160, 163, 164, 178, 179,
  626. 175, 176, 166, 167, 169, 170, 172, 173, 24, 23,
  627. 14, 15, 16, 88, 17, 18, 0, 0, 158, 188,
  628. 189, 155, 153, 154, 230, 227, 0, 0, 0, 54,
  629. 0, 0, 102, 103, 0, 0, 0, 181, 0, 0,
  630. 0, 59, 46, 0, 0, 0, 0, 157, 0, 22,
  631. 0, 186, 0, 0, 229, 55, 90, 0, 123, 112,
  632. 0, 0, 125, 126, 124, 0, 0, 107, 109, 0,
  633. 111, 0, 0, 116, 117, 118, 0, 0, 152, 0,
  634. 0, 182, 180, 187, 0, 0, 0, 0, 0, 119,
  635. 120, 0, 121, 122, 0, 110, 0, 135, 0, 129,
  636. 0, 151, 156, 0, 185, 100, 0, 0, 0, 147,
  637. 148, 0, 142, 0, 137, 0, 0, 108, 0, 128,
  638. 131, 132, 130, 0, 113, 0, 140, 0, 0, 134,
  639. 0, 141, 0, 139, 0, 21, 149, 0, 0, 136,
  640. 143, 138,
  641. };
  642. short yydgoto[] = { 5,
  643. 6, 7, 8, 27, 9, 29, 10, 11, 12, 254,
  644. 255, 256, 102, 55, 56, 57, 13, 31, 20, 44,
  645. 68, 97, 45, 46, 69, 70, 89, 114, 90, 91,
  646. 92, 141, 36, 37, 142, 143, 180, 222, 223, 38,
  647. 110, 111, 98, 121, 162, 163, 164, 165, 166, 167,
  648. 168, 169, 170, 206, 58, 266, 231, 285, 319, 306,
  649. 286, 307, 332, 308, 335, 309, 310, 311, 327, 312,
  650. 313, 314, 315, 316, 317, 339, 340, 341, 356, 375,
  651. 352, 353, 354, 378, 263, 289, 207, 259, 237, 238,
  652. 279, 293, 323, 294, 325, 122, 152, 123, 154, 124,
  653. 125, 126, 127, 32, 59, 60, 61, 78, 14, 15,
  654. 16, 48, 103, 173, 213, 104, 267, 50,
  655. };
  656. short yysindex[] = { -81,
  657. -271, -241, -183, -155, 0, -81, 0, 79, 107, 0,
  658. 0, 0, -136, 0, 0, 0, -52, -52, 0, -35,
  659. -171, -145, -134, 0, 107, 0, 0, 0, 0, -242,
  660. 0, 0, 0, 0, 0, -77, -83, -69, 0, 0,
  661. 0, 0, 166, -56, 195, 0, 0, -48, -65, 0,
  662. 0, 0, 0, 0, 0, 0, 251, 0, 263, 0,
  663. -129, 7, -26, 58, 45, 7, -30, 28, 0, 0,
  664. -231, -88, 0, 7, -242, 0, 0, 0, 0, 75,
  665. 0, 0, 0, 0, -35, 0, 44, 315, 96, 0,
  666. 0, 0, -21, 129, 0, -27, 0, 0, 0, 0,
  667. 0, 0, 100, 104, 0, 0, 124, -56, 7, -33,
  668. 106, 347, 7, 0, 7, 351, 362, 0, -31, 376,
  669. 180, 165, 0, 0, 399, -102, -58, 7, 7, 0,
  670. 0, 0, 0, 0, -133, 171, 0, 186, 187, -142,
  671. 409, 407, 0, 0, 0, 168, 347, 347, -8, 130,
  672. 0, -31, 0, -31, 0, -114, -67, 413, 414, 415,
  673. 416, 0, 0, 0, 0, 0, 0, 0, 0, -42,
  674. -61, 0, 151, 151, 7, 44, 44, 167, 169, -34,
  675. 0, 347, 418, 419, 421, 0, 422, 165, 0, 0,
  676. 0, 0, 0, 0, 0, -209, -209, -209, -209, -139,
  677. -139, -139, -139, -139, -139, 102, 200, 174, 175, 145,
  678. 145, 7, 0, 0, 192, 0, 0, 0, 0, 160,
  679. 0, 141, 0, 0, 347, 0, 0, 0, 205, 427,
  680. 433, 152, 429, 0, 0, 0, 0, 0, 0, 0,
  681. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  682. 0, 0, 0, 0, 0, 0, 435, 385, 0, 0,
  683. 0, 0, 0, 0, 0, 0, 353, 196, 160, 0,
  684. 437, 7, 0, 0, 438, 158, -36, 0, 102, 7,
  685. 442, 0, 0, 441, 444, 86, 423, 0, 443, 0,
  686. 445, 0, 393, 446, 0, 0, 0, 447, 0, 0,
  687. 451, 452, 0, 0, 0, -97, -13, 0, 0, -38,
  688. 0, 0, 0, 0, 0, 0, -110, 176, 0, 423,
  689. 177, 0, 0, 0, 102, 423, 86, -80, 172, 0,
  690. 0, 86, 0, 0, 86, 0, 453, 0, -110, 0,
  691. 72, 0, 0, 454, 0, 0, -37, 0, 0, 0,
  692. 0, 217, 0, 185, 0, 455, -13, 0, 459, 0,
  693. 0, 0, 0, 7, 0, -80, 0, 461, 181, 0,
  694. 463, 0, 183, 0, 235, 0, 0, 465, 181, 0,
  695. 0, 0,
  696. };
  697. short yyrindex[] = { 0,
  698. 0, 0, -28, 0, 0, 487, 0, 502, 65, 0,
  699. 0, 0, 41, 0, 0, 0, 0, 0, 0, 0,
  700. 0, 0, 0, 0, 65, 0, 0, 0, 0, 0,
  701. 0, 0, 0, 0, 35, 0, 0, 0, 0, 0,
  702. 0, -29, 0, 0, 225, 0, 0, 0, 59, 0,
  703. 0, 0, 0, 0, 0, 12, 0, 0, 51, 0,
  704. 55, 0, 0, 0, 0, 0, 0, 36, 0, 0,
  705. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  706. 0, 0, 0, 0, 0, 0, 0, 0, 24, 0,
  707. 0, 0, 0, 0, 0, 118, 0, 0, 0, 0,
  708. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  709. 0, 466, 0, 0, 0, 0, 0, 0, 118, 0,
  710. 38, 23, 0, 0, 118, 11, 0, 0, 0, 0,
  711. 0, 0, 162, 0, 0, 0, 0, 0, 0, -19,
  712. 0, 468, 0, 0, 0, 0, 466, 466, 0, 0,
  713. 0, 118, 0, 118, 0, 0, 0, 0, 0, 0,
  714. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  715. 67, 0, 61, 61, 0, 0, 0, 0, 0, 0,
  716. 0, 0, 0, 0, 0, 0, 0, 26, 0, 0,
  717. 0, 0, 0, 0, 0, 0, 471, 189, 0, -149,
  718. -118, -112, 73, 92, 98, 0, 0, 0, 0, 0,
  719. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  720. 0, 0, 0, 0, 466, 0, 0, 0, 0, 0,
  721. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  722. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  723. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  724. 0, 0, 0, 0, 0, 0, 22, 0, 0, 0,
  725. 0, 0, 0, 0, 0, 0, 0, 0, 420, 0,
  726. 0, 0, 0, 0, 0, 0, 84, 0, 0, 0,
  727. 0, 0, 0, 424, 0, 0, 0, 0, 0, 0,
  728. 0, 0, 0, 0, 0, 473, -11, 0, 0, 0,
  729. 0, 95, 109, 0, 0, 0, 0, 0, 0, 84,
  730. 0, 0, 0, 0, 0, 84, 0, 0, 0, 0,
  731. 0, 0, 0, 0, 0, 0, 77, 0, -7, 0,
  732. 0, 0, 0, 0, 0, 0, 0, 60, 62, 0,
  733. 0, 0, 0, 274, 0, 0, 37, 0, 0, 0,
  734. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  735. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  736. 0, 0,
  737. };
  738. short yygindex[] = { 0,
  739. 0, 508, 0, 0, 509, 491, 0, 0, 0, -190,
  740. 154, 0, 0, 0, -17, 68, 0, 0, 0, 434,
  741. 412, 0, 0, 450, 0, 0, 0, 0, 0, 417,
  742. 0, -104, 13, 40, 0, 340, 0, 303, 255, 42,
  743. 0, 269, 0, 406, 0, 0, 0, 0, 0, 0,
  744. 0, 0, 0, 0, -22, 256, 329, 0, -278, 202,
  745. 0, 198, 0, 197, 0, 221, 0, 0, 0, -163,
  746. -275, -235, -212, 0, 193, 0, 194, 0, 0, 0,
  747. 0, 170, 0, 0, 324, 0, 0, 0, 224, 229,
  748. 0, 0, 0, 0, 0, 386, 0, 383, 0, 425,
  749. 0, 0, 0, 0, 0, 464, 0, 0, 0, 0,
  750. 0, 0, 0, 411, 367, 0, 262, 0,
  751. };
  752. #define YYTABLESIZE 550
  753. short yytable[] = { 35,
  754. 35, 300, 42, 365, 290, 220, 40, 137, 119, 87,
  755. 199, 91, 119, 29, 35, 338, 26, 204, 200, 205,
  756. 56, 228, 190, 62, 334, 191, 331, 105, 53, 105,
  757. 127, 127, 186, 127, 66, 77, 127, 79, 17, 41,
  758. 218, 343, 184, 185, 79, 82, 84, 346, 86, 35,
  759. 209, 199, 349, 42, 213, 91, 105, 26, 236, 39,
  760. 226, 53, 228, 190, 12, 362, 191, 42, 18, 199,
  761. 91, 91, 91, 91, 33, 106, 54, 106, 19, 93,
  762. 228, 190, 62, 150, 191, 33, 331, 43, 292, 131,
  763. 349, 133, 350, 66, 77, 144, 79, 79, 213, 218,
  764. 145, 80, 146, 145, 171, 146, 94, 33, 95, 209,
  765. 172, 172, 105, 213, 162, 351, 127, 236, 305, 226,
  766. 271, 135, 234, 235, 150, 300, 89, 89, 89, 178,
  767. 350, 94, 114, 114, 345, 114, 76, 26, 43, 21,
  768. 175, 22, 150, 77, 116, 177, 115, 115, 136, 115,
  769. 47, 174, 43, 351, 146, 94, 30, 79, 179, 330,
  770. 106, 23, 99, 236, 348, 28, 190, 94, 98, 94,
  771. 94, 49, 94, 229, 230, 230, 233, 361, 337, 270,
  772. 145, 156, 51, 157, 269, 131, 99, 132, 257, 1,
  773. 191, 64, 98, 192, 265, 65, 62, 2, 99, 63,
  774. 99, 99, 348, 99, 98, 374, 98, 98, 158, 98,
  775. 159, 66, 53, 193, 215, 382, 3, 4, 114, 330,
  776. 131, 302, 208, 160, 209, 210, 67, 118, 211, 161,
  777. 100, 118, 115, 101, 132, 41, 281, 194, 71, 269,
  778. 195, 303, 29, 304, 333, 105, 301, 72, 151, 127,
  779. 127, 73, 115, 35, 265, 63, 116, 367, 33, 291,
  780. 366, 257, 265, 302, 33, 34, 120, 199, 199, 88,
  781. 201, 202, 203, 138, 221, 380, 91, 91, 379, 190,
  782. 33, 33, 191, 303, 91, 304, 33, 34, 29, 56,
  783. 33, 81, 228, 106, 62, 91, 74, 91, 91, 66,
  784. 228, 91, 62, 199, 127, 66, 75, 257, 48, 49,
  785. 49, 48, 48, 66, 144, 190, 62, 144, 191, 228,
  786. 228, 62, 62, 33, 91, 91, 91, 66, 77, 236,
  787. 79, 226, 66, 66, 62, 12, 165, 236, 96, 226,
  788. 150, 150, 85, 12, 299, 66, 257, 109, 131, 107,
  789. 132, 114, 114, 95, 112, 168, 236, 236, 226, 226,
  790. 113, 171, 12, 12, 128, 115, 115, 150, 129, 150,
  791. 301, 145, 96, 146, 33, 83, 150, 95, 97, 89,
  792. 89, 89, 249, 131, 206, 140, 206, 302, 206, 95,
  793. 147, 95, 95, 303, 95, 304, 96, 132, 133, 206,
  794. 133, 148, 97, 64, 117, 206, 250, 303, 96, 304,
  795. 96, 96, 139, 96, 97, 150, 97, 97, 33, 97,
  796. 251, 252, 153, 253, 239, 241, 243, 245, 247, 240,
  797. 242, 244, 246, 248, 206, 48, 151, 49, 119, 48,
  798. 33, 130, 107, 183, 216, 217, 117, 176, 177, 181,
  799. 182, 187, 196, 197, 198, 199, 212, 225, 218, 226,
  800. 219, 227, 228, 258, 260, 261, 262, 183, 221, 272,
  801. 273, 274, 276, 275, 277, 278, 280, 283, 287, 288,
  802. 296, 297, 298, 320, 318, 322, 1, 326, 321, 324,
  803. 328, 329, 359, 355, 342, 344, 368, 364, 369, 370,
  804. 373, 5, 303, 376, 377, 381, 50, 31, 51, 101,
  805. 101, 104, 183, 24, 25, 52, 184, 371, 108, 132,
  806. 99, 224, 268, 282, 149, 134, 232, 284, 347, 357,
  807. 336, 358, 360, 363, 264, 372, 189, 188, 106, 174,
  808. 214, 295, 0, 0, 0, 0, 0, 0, 0, 155,
  809. };
  810. short yycheck[] = { 17,
  811. 18, 40, 20, 41, 41, 40, 42, 41, 40, 40,
  812. 0, 0, 40, 42, 44, 126, 46, 60, 61, 62,
  813. 40, 0, 0, 0, 38, 0, 124, 39, 271, 41,
  814. 38, 39, 41, 41, 0, 0, 44, 0, 310, 271,
  815. 0, 320, 147, 148, 62, 63, 64, 326, 66, 67,
  816. 0, 41, 328, 71, 0, 44, 74, 46, 0, 18,
  817. 0, 271, 41, 41, 0, 341, 41, 85, 310, 59,
  818. 59, 60, 61, 62, 317, 39, 319, 41, 262, 67,
  819. 59, 59, 59, 0, 59, 317, 124, 20, 279, 107,
  820. 366, 109, 328, 59, 59, 113, 59, 115, 44, 59,
  821. 41, 62, 41, 44, 127, 44, 67, 317, 67, 59,
  822. 128, 129, 124, 59, 264, 328, 124, 59, 33, 59,
  823. 225, 109, 262, 263, 41, 40, 60, 61, 62, 272,
  824. 366, 281, 38, 39, 325, 41, 266, 59, 71, 295,
  825. 274, 297, 59, 273, 278, 264, 38, 39, 109, 41,
  826. 322, 264, 85, 366, 115, 305, 293, 175, 301, 257,
  827. 124, 317, 281, 303, 328, 59, 281, 317, 281, 319,
  828. 320, 317, 322, 196, 197, 198, 199, 341, 289, 39,
  829. 113, 284, 317, 286, 44, 126, 305, 126, 206, 271,
  830. 305, 275, 305, 308, 212, 265, 274, 279, 317, 277,
  831. 319, 320, 366, 322, 317, 369, 319, 320, 267, 322,
  832. 269, 46, 271, 281, 175, 379, 298, 299, 124, 257,
  833. 126, 302, 284, 282, 286, 287, 283, 259, 290, 288,
  834. 319, 259, 124, 322, 126, 271, 41, 305, 44, 44,
  835. 308, 322, 271, 324, 258, 257, 285, 296, 257, 257,
  836. 258, 317, 274, 283, 272, 277, 278, 41, 317, 277,
  837. 44, 279, 280, 302, 317, 318, 294, 257, 258, 300,
  838. 313, 314, 315, 307, 309, 41, 265, 266, 44, 257,
  839. 317, 317, 257, 322, 273, 324, 317, 318, 317, 309,
  840. 317, 318, 271, 257, 271, 284, 46, 286, 287, 265,
  841. 279, 290, 279, 293, 312, 271, 44, 325, 274, 275,
  842. 276, 277, 278, 279, 41, 293, 293, 44, 293, 298,
  843. 299, 298, 299, 317, 313, 314, 315, 293, 293, 271,
  844. 293, 271, 298, 299, 311, 271, 264, 279, 311, 279,
  845. 257, 258, 298, 279, 259, 311, 364, 304, 289, 275,
  846. 289, 257, 258, 281, 40, 264, 298, 299, 298, 299,
  847. 265, 264, 298, 299, 265, 257, 258, 284, 265, 286,
  848. 285, 312, 281, 312, 317, 318, 293, 305, 281, 313,
  849. 314, 315, 281, 289, 267, 39, 269, 302, 271, 317,
  850. 40, 319, 320, 322, 322, 324, 305, 289, 322, 282,
  851. 324, 40, 305, 275, 276, 288, 305, 322, 317, 324,
  852. 319, 320, 307, 322, 317, 40, 319, 320, 317, 322,
  853. 319, 320, 258, 322, 201, 202, 203, 204, 205, 201,
  854. 202, 203, 204, 205, 317, 274, 257, 276, 40, 278,
  855. 317, 318, 275, 276, 176, 177, 276, 262, 262, 41,
  856. 44, 322, 40, 40, 40, 40, 306, 40, 292, 41,
  857. 292, 41, 41, 264, 291, 291, 322, 276, 309, 265,
  858. 44, 39, 44, 322, 40, 91, 124, 41, 41, 322,
  859. 39, 41, 39, 41, 62, 93, 0, 41, 44, 44,
  860. 40, 40, 40, 322, 319, 319, 312, 44, 44, 41,
  861. 40, 0, 322, 41, 322, 41, 41, 283, 41, 39,
  862. 322, 39, 93, 6, 6, 25, 93, 364, 85, 108,
  863. 71, 182, 220, 269, 119, 109, 198, 272, 327, 332,
  864. 310, 335, 339, 341, 211, 366, 154, 152, 75, 129,
  865. 174, 280, -1, -1, -1, -1, -1, -1, -1, 125,
  866. };
  867. #define YYFINAL 5
  868. #ifndef YYDEBUG
  869. #define YYDEBUG 0
  870. #endif
  871. #define YYMAXTOKEN 325
  872. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  873. char *yyname[] = {
  874. "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  875. "'!'",0,0,0,0,"'&'","'\\''","'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,
  876. 0,0,0,0,0,0,0,0,0,"';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  877. 0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  878. 0,0,0,0,0,0,"'|'",0,"'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  879. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  880. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  881. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"_OR","_AND","_NOT","_UMINUS",
  882. "mHighest","_ALL","_ANY","_ARRAY","_AS","_ASC","_CAST","_COERCE","_CONTAINS",
  883. "_CONTENTS","_CREATE","_DEEP_TRAVERSAL","_DESC","_DOT","_DOTDOT",
  884. "_DOTDOT_SCOPE","_DOTDOTDOT","_DOTDOTDOT_SCOPE","_DROP",
  885. "_EXCLUDE_SEARCH_TRAVERSAL","_FALSE","_FREETEXT","_FROM","_IS","_ISABOUT",
  886. "_IS_NOT","_LIKE","_MATCHES","_NEAR","_NOT_LIKE","_NULL","_OF","_ORDER_BY",
  887. "_PASSTHROUGH","_PROPERTYNAME","_PROPID","_RANKMETHOD","_SELECT","_SET",
  888. "_SCOPE","_SHALLOW_TRAVERSAL","_FORMSOF","_SOME","_TABLE","_TRUE","_TYPE",
  889. "_UNION","_UNKNOWN","_URL","_VIEW","_WHERE","_WEIGHT","_GE","_LE","_NE",
  890. "_CONST","_ID","_TEMPVIEW","_INTNUM","_REALNUM","_SCALAR_FUNCTION_REF",
  891. "_STRING","_DATE","_PREFIX_STRING","_DELIMITED_ID",
  892. };
  893. char *yyrule[] = {
  894. "$accept : entry_point",
  895. "entry_point : definition_list",
  896. "entry_point : definition_list executable_statement",
  897. "entry_point : executable_statement",
  898. "executable_statement : ordered_query_specification semicolon",
  899. "semicolon :",
  900. "semicolon : ';'",
  901. "definition_list : definition_list definition opt_semi",
  902. "definition_list : definition opt_semi",
  903. "definition : create_view_statement",
  904. "definition : drop_view_statement",
  905. "definition : set_statement",
  906. "opt_semi :",
  907. "opt_semi : ';'",
  908. "typed_literal : _INTNUM",
  909. "typed_literal : _REALNUM",
  910. "typed_literal : _STRING",
  911. "typed_literal : relative_date_time",
  912. "typed_literal : boolean_literal",
  913. "unsigned_integer : _INTNUM",
  914. "integer : _INTNUM",
  915. "relative_date_time : identifier '(' identifier ',' _INTNUM ',' relative_date_time ')'",
  916. "relative_date_time : identifier '(' ')'",
  917. "boolean_literal : _TRUE",
  918. "boolean_literal : _FALSE",
  919. "identifier : _ID",
  920. "correlation_name : identifier",
  921. "ordered_query_specification : query_specification opt_order_by_clause",
  922. "query_specification : _SELECT opt_set_quantifier select_list from_clause opt_where_clause",
  923. "opt_set_quantifier :",
  924. "opt_set_quantifier : _ALL",
  925. "select_list : select_sublist",
  926. "select_list : '*'",
  927. "select_sublist : select_sublist ',' derived_column",
  928. "select_sublist : derived_column",
  929. "derived_column : identifier",
  930. "derived_column : correlation_name '.' identifier",
  931. "derived_column : _CREATE",
  932. "from_clause : common_from_clause",
  933. "from_clause : from_view_clause",
  934. "common_from_clause : _FROM scope_specification opt_AS_clause",
  935. "scope_specification : unqualified_scope_specification",
  936. "scope_specification : qualified_scope_specification",
  937. "scope_specification : union_all_scope_specification",
  938. "unqualified_scope_specification : _SCOPE '(' scope_definition ')'",
  939. "qualified_scope_specification : machine_name _DOTDOTDOT_SCOPE '(' scope_definition ')'",
  940. "qualified_scope_specification : machine_name _DOT catalog_name _DOTDOT_SCOPE '(' scope_definition ')'",
  941. "qualified_scope_specification : catalog_name _DOTDOT_SCOPE '(' scope_definition ')'",
  942. "machine_name : identifier",
  943. "catalog_name : identifier",
  944. "scope_definition :",
  945. "scope_definition : scope_element_list",
  946. "scope_element_list : scope_element_list ',' scope_element",
  947. "scope_element_list : scope_element",
  948. "scope_element : '\\'' opt_traversal_exclusivity path_or_virtual_root_list '\\''",
  949. "scope_element : '\\'' opt_traversal_exclusivity '(' path_or_virtual_root_list ')' '\\''",
  950. "opt_traversal_exclusivity :",
  951. "opt_traversal_exclusivity : _DEEP_TRAVERSAL _OF",
  952. "opt_traversal_exclusivity : _SHALLOW_TRAVERSAL _OF",
  953. "path_or_virtual_root_list : path_or_virtual_root_list ',' path_or_virtual_root",
  954. "path_or_virtual_root_list : path_or_virtual_root",
  955. "path_or_virtual_root : _URL",
  956. "opt_AS_clause :",
  957. "opt_AS_clause : _AS correlation_name",
  958. "from_view_clause : _FROM view_name",
  959. "view_name : _TEMPVIEW",
  960. "view_name : identifier",
  961. "view_name : catalog_name _DOTDOT _TEMPVIEW",
  962. "view_name : catalog_name _DOTDOT identifier",
  963. "view_name : machine_name _DOT catalog_name _DOTDOT _TEMPVIEW",
  964. "view_name : machine_name _DOT catalog_name _DOTDOT identifier",
  965. "view_name : machine_name _DOTDOTDOT identifier",
  966. "view_name : machine_name _DOTDOTDOT _TEMPVIEW",
  967. "union_all_scope_specification : '(' union_all_scope_element ')'",
  968. "union_all_scope_element : union_all_scope_element _UNION _ALL explicit_table",
  969. "union_all_scope_element : explicit_table _UNION _ALL explicit_table",
  970. "explicit_table : _TABLE qualified_scope_specification",
  971. "opt_where_clause :",
  972. "opt_where_clause : where_clause",
  973. "where_clause : _WHERE search_condition",
  974. "where_clause : _WHERE _PASSTHROUGH '(' _STRING ')'",
  975. "predicate : comparison_predicate",
  976. "predicate : contains_predicate",
  977. "predicate : freetext_predicate",
  978. "predicate : like_predicate",
  979. "predicate : matches_predicate",
  980. "predicate : vector_comparison_predicate",
  981. "predicate : null_predicate",
  982. "comparison_predicate : column_reference_or_cast comp_op typed_literal",
  983. "column_reference_or_cast : column_reference",
  984. "column_reference_or_cast : _CAST '(' column_reference _AS dbtype ')'",
  985. "column_reference : identifier",
  986. "column_reference : correlation_name '.' identifier",
  987. "column_reference : _CREATE",
  988. "comp_op : '='",
  989. "comp_op : _NE",
  990. "comp_op : '<'",
  991. "comp_op : '>'",
  992. "comp_op : _LE",
  993. "comp_op : _GE",
  994. "contains_predicate : _CONTAINS '(' opt_contents_column_reference '\\'' content_search_condition '\\'' ')' opt_greater_than_zero",
  995. "opt_contents_column_reference :",
  996. "opt_contents_column_reference : column_reference ','",
  997. "$$1 :",
  998. "content_search_condition : $$1 content_search_cond",
  999. "content_search_cond : content_boolean_term",
  1000. "content_search_cond : content_search_cond or_operator content_boolean_term",
  1001. "content_boolean_term : content_boolean_factor",
  1002. "content_boolean_term : content_boolean_term and_operator content_boolean_factor",
  1003. "content_boolean_factor : content_boolean_primary",
  1004. "content_boolean_factor : not_operator content_boolean_primary",
  1005. "content_boolean_primary : content_search_term",
  1006. "$$2 :",
  1007. "content_boolean_primary : '(' $$2 content_search_cond ')'",
  1008. "content_search_term : simple_term",
  1009. "content_search_term : prefix_term",
  1010. "content_search_term : proximity_term",
  1011. "content_search_term : stemming_term",
  1012. "content_search_term : isabout_term",
  1013. "or_operator : _OR",
  1014. "or_operator : '|'",
  1015. "and_operator : _AND",
  1016. "and_operator : '&'",
  1017. "not_operator : _NOT",
  1018. "not_operator : '!'",
  1019. "simple_term : _STRING",
  1020. "prefix_term : _PREFIX_STRING",
  1021. "proximity_term : proximity_operand proximity_expression_list",
  1022. "proximity_expression_list : proximity_expression_list proximity_expression",
  1023. "proximity_expression_list : proximity_expression",
  1024. "proximity_expression : proximity_specification proximity_operand",
  1025. "proximity_operand : simple_term",
  1026. "proximity_operand : prefix_term",
  1027. "proximity_specification : _NEAR",
  1028. "proximity_specification : _NEAR '(' ')'",
  1029. "proximity_specification : '~'",
  1030. "stemming_term : _FORMSOF '(' stem_type ',' stemmed_simple_term_list ')'",
  1031. "stem_type : _STRING",
  1032. "stemmed_simple_term_list : stemmed_simple_term_list ',' simple_term",
  1033. "stemmed_simple_term_list : simple_term",
  1034. "isabout_term : _ISABOUT '(' vector_component_list ')'",
  1035. "vector_component_list : vector_component_list ',' vector_component",
  1036. "vector_component_list : vector_component",
  1037. "vector_component : vector_term _WEIGHT '(' weight_value ')'",
  1038. "vector_component : vector_term",
  1039. "vector_term : simple_term",
  1040. "vector_term : prefix_term",
  1041. "vector_term : proximity_term",
  1042. "vector_term : stemming_term",
  1043. "weight_value : _STRING",
  1044. "opt_greater_than_zero :",
  1045. "opt_greater_than_zero : '>' _INTNUM",
  1046. "freetext_predicate : _FREETEXT '(' opt_contents_column_reference _STRING ')' opt_greater_than_zero",
  1047. "like_predicate : column_reference _LIKE wildcard_search_pattern",
  1048. "like_predicate : column_reference _NOT_LIKE wildcard_search_pattern",
  1049. "wildcard_search_pattern : _STRING",
  1050. "matches_predicate : _MATCHES '(' column_reference ',' matches_string ')' opt_greater_than_zero",
  1051. "matches_string : _STRING",
  1052. "vector_comparison_predicate : column_reference_or_cast vector_comp_op vector_literal",
  1053. "all : _ALL",
  1054. "some : _SOME",
  1055. "some : _ANY",
  1056. "vector_comp_op : '='",
  1057. "vector_comp_op : '=' all",
  1058. "vector_comp_op : '=' some",
  1059. "vector_comp_op : _NE",
  1060. "vector_comp_op : _NE all",
  1061. "vector_comp_op : _NE some",
  1062. "vector_comp_op : '<'",
  1063. "vector_comp_op : '<' all",
  1064. "vector_comp_op : '<' some",
  1065. "vector_comp_op : '>'",
  1066. "vector_comp_op : '>' all",
  1067. "vector_comp_op : '>' some",
  1068. "vector_comp_op : _LE",
  1069. "vector_comp_op : _LE all",
  1070. "vector_comp_op : _LE some",
  1071. "vector_comp_op : _GE",
  1072. "vector_comp_op : _GE all",
  1073. "vector_comp_op : _GE some",
  1074. "vector_literal : _ARRAY left_sqbrkt opt_literal_list right_sqbrkt",
  1075. "left_sqbrkt : '['",
  1076. "right_sqbrkt : ']'",
  1077. "opt_literal_list :",
  1078. "opt_literal_list : literal_list",
  1079. "literal_list : literal_list comma typed_literal",
  1080. "literal_list : typed_literal",
  1081. "comma : ','",
  1082. "null_predicate : column_reference _IS _NULL",
  1083. "null_predicate : column_reference _IS_NOT _NULL",
  1084. "search_condition : boolean_term",
  1085. "search_condition : search_condition or_op boolean_term",
  1086. "boolean_term : boolean_factor",
  1087. "boolean_term : boolean_term and_op boolean_factor",
  1088. "boolean_factor : boolean_test",
  1089. "boolean_factor : not_op boolean_test",
  1090. "or_op : _OR",
  1091. "and_op : _AND",
  1092. "not_op : _NOT",
  1093. "boolean_test : boolean_primary",
  1094. "boolean_test : boolean_primary _IS _TRUE",
  1095. "boolean_test : boolean_primary _IS _FALSE",
  1096. "boolean_test : boolean_primary _IS _UNKNOWN",
  1097. "boolean_test : boolean_primary _IS_NOT _TRUE",
  1098. "boolean_test : boolean_primary _IS_NOT _FALSE",
  1099. "boolean_test : boolean_primary _IS_NOT _UNKNOWN",
  1100. "$$3 :",
  1101. "boolean_primary : $$3 predicate",
  1102. "boolean_primary : '(' search_condition ')'",
  1103. "order_by_clause : _ORDER_BY sort_specification_list",
  1104. "sort_specification_list : sort_specification_list ',' sort_specification",
  1105. "sort_specification_list : sort_specification",
  1106. "sort_specification : sort_key opt_ordering_specification",
  1107. "opt_ordering_specification :",
  1108. "opt_ordering_specification : _ASC",
  1109. "opt_ordering_specification : _DESC",
  1110. "sort_key : column_reference",
  1111. "sort_key : integer",
  1112. "opt_order_by_clause :",
  1113. "opt_order_by_clause : order_by_clause",
  1114. "set_statement : set_propertyname_statement",
  1115. "set_statement : set_rankmethod_statement",
  1116. "set_statement : set_global_directive",
  1117. "set_propertyname_statement : _SET _PROPERTYNAME guid_format _PROPID property_id _AS column_alias opt_type_clause",
  1118. "set_propertyname_statement : _SET _PROPERTYNAME guid_format _PROPID property_name _AS column_alias opt_type_clause",
  1119. "column_alias : identifier",
  1120. "opt_type_clause :",
  1121. "opt_type_clause : _TYPE dbtype",
  1122. "dbtype : base_dbtype",
  1123. "dbtype : base_dbtype '|' base_dbtype",
  1124. "base_dbtype : identifier",
  1125. "property_id : unsigned_integer",
  1126. "property_name : _STRING",
  1127. "guid_format : _STRING",
  1128. "set_rankmethod_statement : _SET _RANKMETHOD rankmethod",
  1129. "rankmethod : _ID _ID",
  1130. "rankmethod : _ID",
  1131. "set_global_directive : _SET _ID _ID",
  1132. "create_view_statement : _CREATE _VIEW view_name _AS _SELECT select_list from_clause",
  1133. "drop_view_statement : _DROP _VIEW view_name",
  1134. };
  1135. #endif
  1136. #ifndef YYSTYPE
  1137. typedef int YYSTYPE;
  1138. #endif
  1139. YYPARSER::YYPARSER(CImpIParserSession* pParserSession, CImpIParserTreeProperties* pParserTreeProperties, YYLEXER & yylex)
  1140. : CYYBase( pParserSession, pParserTreeProperties, yylex ) {
  1141. xyyvs.SetSize(INITSTACKSIZE);
  1142. yydebug = 0;
  1143. }
  1144. #define YYABORT(sc) { EmptyValueStack( yylval ); return ResultFromScode(sc); }
  1145. #define YYFATAL QPARSE_E_INVALID_QUERY
  1146. #define YYSUCCESS S_OK
  1147. #define YYREJECT goto yyabort
  1148. #define YYACCEPT goto yyaccept
  1149. int mystrlen(char * str)
  1150. {
  1151. Win4Assert( 0 != str );
  1152. int i = 0;
  1153. while ( 0 != str[i] )
  1154. i++;
  1155. return i;
  1156. }
  1157. void YYPARSER::ResetParser()
  1158. {
  1159. yynerrs = 0;
  1160. yyerrflag = 0;
  1161. yychar = (-1);
  1162. yyssp = xyyss.Get();
  1163. yyvsp = xyyvs.Get();
  1164. *yyssp = 0;
  1165. }
  1166. void YYPARSER::PopVs()
  1167. {
  1168. if ( NULL != *yyvsp )
  1169. DeleteDBQT(*yyvsp);
  1170. yyvsp--;
  1171. }
  1172. void YYPARSER::EmptyValueStack( YYAPI_VALUETYPE yylval )
  1173. {
  1174. if ( yyvsp != NULL )
  1175. {
  1176. if ((*yyvsp != yylval) && (NULL != yylval))
  1177. DeleteDBQT(yylval);
  1178. unsigned cCount = (unsigned)ULONG_PTR(yyvsp - xyyvs.Get());
  1179. for ( unsigned i=0; i < cCount; i++ )
  1180. {
  1181. if (NULL != xyyvs[i] )
  1182. DeleteDBQT(xyyvs[i]);
  1183. }
  1184. }
  1185. //@TODO RE-ACTIVATE
  1186. // note: This was only done to empty any scope arrays
  1187. // m_pIPSession->SetScopeProperties(m_pICommand);
  1188. m_pIPTProperties->SetContainsColumn(NULL);
  1189. }
  1190. int YYPARSER::Parse()
  1191. {
  1192. register int yym, yyn, yystate;
  1193. #if YYDEBUG
  1194. register char *yys;
  1195. if (yys = getenv("YYDEBUG"))
  1196. {
  1197. yyn = *yys;
  1198. if (yyn >= '0' && yyn <= '9')
  1199. yydebug = yyn - '0';
  1200. }
  1201. #endif
  1202. yynerrs = 0;
  1203. yyerrflag = 0;
  1204. yychar = (-1);
  1205. yyssp = xyyss.Get();
  1206. yyvsp = xyyvs.Get();
  1207. *yyssp = yystate = 0;
  1208. yyloop:
  1209. if (yyn = yydefred[yystate]) goto yyreduce;
  1210. if (yychar < 0)
  1211. {
  1212. YYAPI_VALUENAME = NULL;
  1213. try
  1214. {
  1215. if ( (yychar = YYLEX(&YYAPI_VALUENAME)) < 0 )
  1216. yychar = 0;
  1217. }
  1218. catch (HRESULT hr)
  1219. {
  1220. switch(hr)
  1221. {
  1222. case E_OUTOFMEMORY:
  1223. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1224. YYABORT(E_OUTOFMEMORY);
  1225. break;
  1226. default:
  1227. YYABORT(QPARSE_E_INVALID_QUERY);
  1228. break;
  1229. }
  1230. }
  1231. #if YYDEBUG
  1232. if (yydebug)
  1233. {
  1234. yys = 0;
  1235. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1236. if (!yys) yys = "illegal-symbol";
  1237. printf("%sdebug: state %d, reading %d (%s)\n",
  1238. YYPREFIX, yystate, yychar, yys);
  1239. }
  1240. #endif
  1241. }
  1242. if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
  1243. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1244. {
  1245. #if YYDEBUG
  1246. if (yydebug)
  1247. printf("%sdebug: state %d, shifting to state %d\n",
  1248. YYPREFIX, yystate, yytable[yyn]);
  1249. #endif
  1250. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  1251. {
  1252. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  1253. xyyss.SetSize((unsigned) (yyssp-xyyss.Get())+2);
  1254. yyssp = xyyss.Get() + yysspLoc;
  1255. }
  1256. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  1257. {
  1258. int yyvspLoc = (int) ( yyvsp - xyyvs.Get() );
  1259. xyyvs.SetSize((unsigned) (yyvsp-xyyvs.Get())+2);
  1260. yyvsp = xyyvs.Get() + yyvspLoc;
  1261. }
  1262. *++yyssp = yystate = yytable[yyn];
  1263. *++yyvsp = yylval;
  1264. yychar = (-1);
  1265. if (yyerrflag > 0) --yyerrflag;
  1266. goto yyloop;
  1267. }
  1268. if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
  1269. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1270. {
  1271. yyn = yytable[yyn];
  1272. goto yyreduce;
  1273. }
  1274. #ifdef YYERROR_VERBOSE
  1275. // error reporting; done before the goto error recovery
  1276. {
  1277. // must be first - cleans m_pIPTProperties
  1278. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  1279. int size = 0, totSize = 0;
  1280. int curr_yychar;
  1281. XGrowable<WCHAR> xMsg;
  1282. for ( curr_yychar =0; curr_yychar<=YYMAXTOKEN; curr_yychar++)
  1283. {
  1284. if ( ( yycheck[yysindex[yystate] + curr_yychar] == curr_yychar ) ||
  1285. ( yycheck[yyrindex[yystate] + curr_yychar] == curr_yychar ) )
  1286. {
  1287. char * token_name = yyname[curr_yychar];
  1288. if ( 0 != token_name )
  1289. {
  1290. if ( '_' == token_name[0] )
  1291. token_name++;
  1292. size = mystrlen(token_name) + 1 ;
  1293. xMsg.SetSize(totSize+size+2); // +2 for ", "
  1294. if (0 == MultiByteToWideChar(CP_ACP, 0, token_name, size,
  1295. xMsg.Get()+totSize, size))
  1296. {
  1297. break;
  1298. }
  1299. totSize += size-1;
  1300. wcscpy( xMsg.Get()+totSize, L", " );
  1301. totSize+=2;
  1302. }
  1303. }
  1304. }
  1305. // get rid of last comma
  1306. if ( totSize >= 2 )
  1307. (xMsg.Get())[totSize-2] = 0;
  1308. if ( wcslen((YY_CHAR*)m_yylex.YYText()) )
  1309. m_pIPTProperties->SetErrorToken( (YY_CHAR*)m_yylex.YYText() );
  1310. else
  1311. m_pIPTProperties->SetErrorToken(L"<end of input>");
  1312. m_pIPTProperties->SetErrorToken(xMsg.Get());
  1313. }
  1314. #endif //YYERROR_VERBOSE
  1315. if (yyerrflag) goto yyinrecovery;
  1316. yyerror("syntax error");
  1317. ++yynerrs;
  1318. yyinrecovery:
  1319. if (yyerrflag < 3)
  1320. {
  1321. yyerrflag = 3;
  1322. for (;;)
  1323. {
  1324. if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
  1325. yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  1326. {
  1327. #if YYDEBUG
  1328. if (yydebug)
  1329. printf("%sdebug: state %d, error recovery shifting\
  1330. to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
  1331. #endif
  1332. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  1333. {
  1334. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  1335. xyyss.SetSize((unsigned) (yyssp-xyyss.Get())+2);
  1336. yyssp = xyyss.Get() + yysspLoc;
  1337. }
  1338. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  1339. {
  1340. int yyvspLoc = (int) ( yyvsp - xyyvs.Get() );
  1341. xyyvs.SetSize((unsigned) (yyvsp-xyyvs.Get())+2);
  1342. yyvsp = xyyvs.Get() + yyvspLoc;
  1343. }
  1344. *++yyssp = yystate = yytable[yyn];
  1345. *++yyvsp = yylval;
  1346. goto yyloop;
  1347. }
  1348. else
  1349. {
  1350. #if YYDEBUG
  1351. if (yydebug)
  1352. printf("%sdebug: error recovery discarding state %d\
  1353. ",
  1354. YYPREFIX, *yyssp);
  1355. #endif
  1356. if (yyssp <= xyyss.Get()) goto yyabort;
  1357. PopVs();
  1358. --yyssp;
  1359. }
  1360. }
  1361. }
  1362. else
  1363. {
  1364. if (yychar == 0) goto yyabort;
  1365. #if YYDEBUG
  1366. if (yydebug)
  1367. {
  1368. yys = 0;
  1369. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1370. if (!yys) yys = "illegal-symbol";
  1371. printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
  1372. YYPREFIX, yystate, yychar, yys);
  1373. }
  1374. #endif
  1375. yychar = (-1);
  1376. goto yyloop;
  1377. }
  1378. yyreduce:
  1379. #if YYDEBUG
  1380. if (yydebug)
  1381. printf("%sdebug: state %d, reducing by rule %d (%s)\n",
  1382. YYPREFIX, yystate, yyn, yyrule[yyn]);
  1383. #endif
  1384. yym = yylen[yyn];
  1385. yyval = yyvsp[1-yym];
  1386. switch (yyn)
  1387. {
  1388. case 1:
  1389. {
  1390. yyval = NULL;
  1391. }
  1392. break;
  1393. case 2:
  1394. {
  1395. yyval = yyvsp[0];
  1396. }
  1397. break;
  1398. case 3:
  1399. {
  1400. yyval = yyvsp[0];
  1401. }
  1402. break;
  1403. case 4:
  1404. {
  1405. if (yyvsp[0])
  1406. {
  1407. /* There is a semicolon, either as a statement terminator or as*/
  1408. /* a statement separator. We don't allow either of those.*/
  1409. m_pIPTProperties->SetErrorHResult(DB_E_MULTIPLESTATEMENTS, MONSQL_SEMI_COLON);
  1410. YYABORT(DB_E_MULTIPLESTATEMENTS);
  1411. }
  1412. yyval = yyvsp[-1];
  1413. }
  1414. break;
  1415. case 5:
  1416. {
  1417. yyval = NULL;
  1418. }
  1419. break;
  1420. case 6:
  1421. {
  1422. yyval = PctAllocNode(DBVALUEKIND_NULL, DBOP_NULL);
  1423. }
  1424. break;
  1425. case 7:
  1426. {
  1427. yyval = NULL;
  1428. }
  1429. break;
  1430. case 8:
  1431. {
  1432. yyval = NULL;
  1433. }
  1434. break;
  1435. case 9:
  1436. {
  1437. yyval = NULL;
  1438. }
  1439. break;
  1440. case 10:
  1441. {
  1442. yyval = NULL;
  1443. }
  1444. break;
  1445. case 11:
  1446. {
  1447. yyval = NULL;
  1448. }
  1449. break;
  1450. case 14:
  1451. {
  1452. AssertReq(yyvsp[0]);
  1453. Assert(VT_UI8 == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt ||
  1454. VT_I8 == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt ||
  1455. VT_BSTR == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt);
  1456. m_pIPTProperties->AppendCiRestriction((YY_CHAR*)m_yylex.YYText(), wcslen(m_yylex.YYText()));
  1457. HRESULT hr = CoerceScalar(m_pIPTProperties->GetDBType(), &yyvsp[0]);
  1458. if (S_OK != hr)
  1459. YYABORT(hr);
  1460. yyval = yyvsp[0];
  1461. }
  1462. break;
  1463. case 15:
  1464. {
  1465. AssertReq(yyvsp[0]);
  1466. Assert(VT_R8 == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt ||
  1467. VT_BSTR == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt);
  1468. m_pIPTProperties->AppendCiRestriction((YY_CHAR*)m_yylex.YYText(), wcslen(m_yylex.YYText()));
  1469. HRESULT hr = CoerceScalar(m_pIPTProperties->GetDBType(), &yyvsp[0]);
  1470. if (S_OK != hr)
  1471. YYABORT(hr);
  1472. yyval = yyvsp[0];
  1473. }
  1474. break;
  1475. case 16:
  1476. {
  1477. AssertReq(yyvsp[0]);
  1478. Assert(VT_BSTR == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt);
  1479. if (VT_DATE == m_pIPTProperties->GetDBType() ||
  1480. VT_FILETIME == m_pIPTProperties->GetDBType())
  1481. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal,
  1482. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal));
  1483. else
  1484. {
  1485. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  1486. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal,
  1487. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal));
  1488. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  1489. }
  1490. HRESULT hr = CoerceScalar(m_pIPTProperties->GetDBType(), &yyvsp[0]);
  1491. if (S_OK != hr)
  1492. YYABORT(hr);
  1493. yyval = yyvsp[0];
  1494. }
  1495. break;
  1496. case 17:
  1497. {
  1498. AssertReq(yyvsp[0]);
  1499. Assert(VT_FILETIME == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt);
  1500. SYSTEMTIME stValue = {0, 0, 0, 0, 0, 0, 0, 0};
  1501. if (FileTimeToSystemTime(&(((PROPVARIANT*)yyvsp[0]->value.pvValue)->filetime), &stValue))
  1502. {
  1503. WCHAR wchDateTime[50];
  1504. if (NULL == wchDateTime)
  1505. {
  1506. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1507. YYABORT(E_OUTOFMEMORY);
  1508. }
  1509. int cItems = swprintf(wchDateTime, L" %4d/%02d/%02d %02d:%02d:%02d",
  1510. stValue.wYear,
  1511. stValue.wMonth,
  1512. stValue.wDay,
  1513. stValue.wHour,
  1514. stValue.wMinute,
  1515. stValue.wSecond);
  1516. m_pIPTProperties->AppendCiRestriction(wchDateTime, wcslen(wchDateTime));
  1517. }
  1518. HRESULT hr = CoerceScalar(m_pIPTProperties->GetDBType(), &yyvsp[0]);
  1519. if (S_OK != hr)
  1520. YYABORT(hr);
  1521. yyval = yyvsp[0];
  1522. }
  1523. break;
  1524. case 18:
  1525. {
  1526. m_pIPTProperties->AppendCiRestriction((YY_CHAR*)m_yylex.YYText(), wcslen(m_yylex.YYText()));
  1527. HRESULT hr = CoerceScalar(m_pIPTProperties->GetDBType(), &yyvsp[0]);
  1528. if (S_OK != hr)
  1529. YYABORT(hr);
  1530. yyval = yyvsp[0];
  1531. }
  1532. break;
  1533. case 19:
  1534. {
  1535. HRESULT hr = CoerceScalar(VT_UI4, &yyvsp[0]);
  1536. if (S_OK != hr)
  1537. YYABORT(hr);
  1538. yyval = yyvsp[0];
  1539. }
  1540. break;
  1541. case 20:
  1542. {
  1543. HRESULT hr = CoerceScalar(VT_I4, &yyvsp[0]);
  1544. if (S_OK != hr)
  1545. YYABORT(hr);
  1546. yyval = yyvsp[0];
  1547. }
  1548. break;
  1549. case 21:
  1550. {
  1551. /* should be DateAdd(<datepart>, <negative integer>, <relative date/time>)*/
  1552. AssertReq(yyvsp[-7]);
  1553. AssertReq(yyvsp[-5]);
  1554. AssertReq(yyvsp[-3]);
  1555. AssertReq(yyvsp[-1]);
  1556. if (0 != _wcsicmp(L"DateAdd", yyvsp[-7]->value.pwszValue))
  1557. {
  1558. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  1559. m_pIPTProperties->SetErrorToken(yyvsp[-7]->value.pwszValue);
  1560. m_pIPTProperties->SetErrorToken(L"DateAdd");
  1561. YYABORT(DB_E_ERRORSINCOMMAND);
  1562. }
  1563. HRESULT hr = CoerceScalar(VT_I4, &yyvsp[-3]);
  1564. if (S_OK != hr)
  1565. YYABORT(hr);
  1566. if (((PROPVARIANT*)yyvsp[-3]->value.pvValue)->iVal > 0)
  1567. {
  1568. WCHAR wchError[30];
  1569. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  1570. swprintf(wchError, L"%d", ((PROPVARIANT*)yyvsp[-3]->value.pvValue)->iVal);
  1571. m_pIPTProperties->SetErrorToken(wchError);
  1572. swprintf(wchError, L"%d", -((PROPVARIANT*)yyvsp[-3]->value.pvValue)->iVal);
  1573. m_pIPTProperties->SetErrorToken(wchError);
  1574. YYABORT(DB_E_ERRORSINCOMMAND);
  1575. }
  1576. LARGE_INTEGER hWeek = {686047232, 1408};
  1577. LARGE_INTEGER hDay = {711573504, 201};
  1578. LARGE_INTEGER hHour = {1640261632, 8};
  1579. LARGE_INTEGER hMinute = {600000000, 0};
  1580. LARGE_INTEGER hSecond = {10000000, 0};
  1581. LARGE_INTEGER hIncr = {0,0};
  1582. bool fHandleMonth = false;
  1583. ULONG ulMonths = 1;
  1584. switch ( yyvsp[-5]->value.pwszValue[0] )
  1585. {
  1586. case L'Y':
  1587. case L'y':
  1588. if (0 == (_wcsicmp(L"YY", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"YEAR", yyvsp[-5]->value.pwszValue)))
  1589. {
  1590. /* fall through and handle as 12 months*/
  1591. ulMonths = 12;
  1592. }
  1593. case L'Q':
  1594. case L'q':
  1595. if (0 == (_wcsicmp(L"QQ", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"QUARTER", yyvsp[-5]->value.pwszValue)))
  1596. {
  1597. /* fall through and handle as 3 months*/
  1598. ulMonths = 3;
  1599. }
  1600. case L'M':
  1601. case L'm':
  1602. if ( 0 == (_wcsicmp(L"YY", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"YEAR", yyvsp[-5]->value.pwszValue)) ||
  1603. 0 == (_wcsicmp(L"QQ", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"QUARTER", yyvsp[-5]->value.pwszValue)) ||
  1604. 0 == (_wcsicmp(L"MM", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"MONTH", yyvsp[-5]->value.pwszValue)))
  1605. {
  1606. /**/
  1607. /* Convert to system time*/
  1608. /**/
  1609. SYSTEMTIME st = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1610. FileTimeToSystemTime( &((PROPVARIANT*)yyvsp[-1]->value.pvValue)->filetime, &st );
  1611. LONGLONG llDays = 0;
  1612. LONG lMonthsLeft = ulMonths * -((PROPVARIANT*)yyvsp[-3]->value.pvValue)->iVal;
  1613. LONG yr = st.wYear;
  1614. LONG lCurMonth = st.wMonth-1;
  1615. while ( lMonthsLeft )
  1616. {
  1617. LONG lMonthsDone = 1;
  1618. while ( lMonthsDone<=lMonthsLeft )
  1619. {
  1620. /* Will we still be in the current year when looking at the prev month?*/
  1621. if ( 0 == lCurMonth )
  1622. break;
  1623. /* Subtract the number of days in the previous month. We will adjust*/
  1624. llDays += DaysInMonth( yr, lCurMonth-1);
  1625. lMonthsDone++;
  1626. lCurMonth--;
  1627. }
  1628. /* Months left over in prev year*/
  1629. lMonthsLeft -= lMonthsDone-1;
  1630. if ( 0 != lMonthsLeft )
  1631. {
  1632. yr--;
  1633. lCurMonth = 12; /* 11 is December.*/
  1634. }
  1635. }
  1636. /**/
  1637. /* adjust current date to at most max of destination month*/
  1638. /**/
  1639. if ( llDays > 0 && st.wDay > DaysInMonth(yr, lCurMonth-1) )
  1640. llDays += st.wDay - DaysInMonth(yr, lCurMonth-1);
  1641. hIncr.QuadPart = hDay.QuadPart * llDays;
  1642. fHandleMonth = true;
  1643. }
  1644. else if (0 == (_wcsicmp(L"MI", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"MINUTE", yyvsp[-5]->value.pwszValue)))
  1645. hIncr = hMinute;
  1646. break;
  1647. case L'W':
  1648. case L'w':
  1649. if (0 == (_wcsicmp(L"WK", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"WEEK", yyvsp[-5]->value.pwszValue)))
  1650. hIncr = hWeek;
  1651. break;
  1652. case L'D':
  1653. case L'd':
  1654. if (0 == (_wcsicmp(L"DD", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"DAY", yyvsp[-5]->value.pwszValue)))
  1655. hIncr = hDay;
  1656. break;
  1657. case L'H':
  1658. case L'h':
  1659. if (0 == (_wcsicmp(L"HH", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"HOUR", yyvsp[-5]->value.pwszValue)))
  1660. hIncr = hHour;
  1661. break;
  1662. case L'S':
  1663. case L's':
  1664. if (0 == (_wcsicmp(L"SS", yyvsp[-5]->value.pwszValue) & _wcsicmp(L"SECOND", yyvsp[-5]->value.pwszValue)))
  1665. hIncr = hSecond;
  1666. break;
  1667. default:
  1668. break;
  1669. }
  1670. if (0 == hIncr.LowPart && 0 == hIncr.HighPart)
  1671. {
  1672. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  1673. m_pIPTProperties->SetErrorToken(yyvsp[-5]->value.pwszValue);
  1674. m_pIPTProperties->SetErrorToken(
  1675. L"YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND");
  1676. YYABORT(DB_E_ERRORSINCOMMAND);
  1677. }
  1678. if ( fHandleMonth )
  1679. {
  1680. ((PROPVARIANT*)yyvsp[-1]->value.pvValue)->hVal.QuadPart -= hIncr.QuadPart;
  1681. #ifdef DEBUG
  1682. SYSTEMTIME st1 = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1683. FileTimeToSystemTime( &((PROPVARIANT*)yyvsp[-1]->value.pvValue)->filetime, &st1 );
  1684. #endif
  1685. }
  1686. else
  1687. {
  1688. for (int i = 0; i < -((PROPVARIANT*)yyvsp[-3]->value.pvValue)->iVal; i++)
  1689. ((PROPVARIANT*)yyvsp[-1]->value.pvValue)->hVal.QuadPart -= hIncr.QuadPart;
  1690. }
  1691. yyval = yyvsp[-1];
  1692. DeleteDBQT(yyvsp[-7]);
  1693. DeleteDBQT(yyvsp[-5]);
  1694. DeleteDBQT(yyvsp[-3]);
  1695. }
  1696. break;
  1697. case 22:
  1698. {
  1699. /* should be getgmdate()*/
  1700. AssertReq(yyvsp[-2]);
  1701. if (0 != _wcsicmp(L"GetGMTDate", yyvsp[-2]->value.pwszValue))
  1702. {
  1703. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  1704. m_pIPTProperties->SetErrorToken(yyvsp[-2]->value.pwszValue);
  1705. m_pIPTProperties->SetErrorToken(L"GetGMTDate");
  1706. YYABORT(DB_E_ERRORSINCOMMAND);
  1707. }
  1708. DeleteDBQT(yyvsp[-2]);
  1709. yyvsp[-2] = 0;
  1710. yyval = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  1711. if (NULL == yyval)
  1712. {
  1713. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1714. YYABORT(E_OUTOFMEMORY);
  1715. }
  1716. HRESULT hr = CoFileTimeNow(&(((PROPVARIANT*)yyval->value.pvValue)->filetime));
  1717. ((PROPVARIANT*)yyval->value.pvValue)->vt = VT_FILETIME;
  1718. }
  1719. break;
  1720. case 23:
  1721. {
  1722. yyval = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  1723. if (NULL == yyval)
  1724. {
  1725. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1726. YYABORT(E_OUTOFMEMORY);
  1727. }
  1728. ((PROPVARIANT*)yyval->value.pvValue)->vt = VT_BOOL;
  1729. ((PROPVARIANT*)yyval->value.pvValue)->boolVal = VARIANT_TRUE;
  1730. }
  1731. break;
  1732. case 24:
  1733. {
  1734. yyval = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  1735. if (NULL == yyval)
  1736. {
  1737. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1738. YYABORT(E_OUTOFMEMORY);
  1739. }
  1740. ((PROPVARIANT*)yyval->value.pvValue)->vt = VT_BOOL;
  1741. ((PROPVARIANT*)yyval->value.pvValue)->boolVal = VARIANT_FALSE;
  1742. }
  1743. break;
  1744. case 27:
  1745. {
  1746. AssertReq(yyvsp[-1]); /* need a query specification tree*/
  1747. if (NULL != yyvsp[0]) /* add optional ORDER BY nodes*/
  1748. {
  1749. /* Is project list built correctly?*/
  1750. AssertReq(yyvsp[-1]->pctFirstChild);
  1751. AssertReq(yyvsp[-1]->pctFirstChild->pctNextSibling);
  1752. AssertReq(yyvsp[-1]->pctFirstChild->pctNextSibling->pctFirstChild);
  1753. Assert((yyvsp[-1]->op == DBOP_project) &&
  1754. (yyvsp[-1]->pctFirstChild->pctNextSibling->op == DBOP_project_list_anchor));
  1755. DBCOMMANDTREE* pctSortList = yyvsp[0]->pctFirstChild;
  1756. AssertReq(pctSortList);
  1757. while (pctSortList)
  1758. {
  1759. /* Is sort list built correctly?*/
  1760. Assert(pctSortList->op == DBOP_sort_list_element);
  1761. AssertReq(pctSortList->pctFirstChild);
  1762. Assert((pctSortList->pctFirstChild->op == DBOP_column_name) ||
  1763. (pctSortList->pctFirstChild->op == DBOP_scalar_constant));
  1764. if (pctSortList->pctFirstChild->op == DBOP_scalar_constant)
  1765. {
  1766. /* we've got an ordinal rather than a column number, so we've got to*/
  1767. /* walk through the project list to find the corresponding column*/
  1768. Assert(DBVALUEKIND_VARIANT == pctSortList->pctFirstChild->wKind);
  1769. Assert(VT_I4 == pctSortList->pctFirstChild->value.pvarValue->vt);
  1770. DBCOMMANDTREE* pctProjectList = yyvsp[-1]->pctFirstChild->pctNextSibling->pctFirstChild;
  1771. AssertReq(pctProjectList);
  1772. LONG cProjectListElements = GetNumberOfSiblings(pctProjectList);
  1773. if ((cProjectListElements < pctSortList->pctFirstChild->value.pvarValue->lVal) ||
  1774. (0 >= pctSortList->pctFirstChild->value.pvarValue->lVal))
  1775. {
  1776. /* ordinal is larger than number of elements in project list*/
  1777. WCHAR wchError[30];
  1778. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_ORDINAL_OUT_OF_RANGE);
  1779. swprintf(wchError, L"%d", pctSortList->pctFirstChild->value.pvarValue->lVal);
  1780. m_pIPTProperties->SetErrorToken(wchError);
  1781. swprintf(wchError, L"%d", cProjectListElements);
  1782. m_pIPTProperties->SetErrorToken(wchError);
  1783. YYABORT(DB_E_ERRORSINCOMMAND);
  1784. }
  1785. else
  1786. {
  1787. LONG lColumnNumber = 1;
  1788. while (pctProjectList &&
  1789. (lColumnNumber < pctSortList->pctFirstChild->value.pvarValue->lVal))
  1790. {
  1791. /* find the ulVal'th column in the project list*/
  1792. Assert(pctProjectList->op == DBOP_project_list_element);
  1793. pctProjectList = pctProjectList->pctNextSibling;
  1794. lColumnNumber++;
  1795. }
  1796. DeleteDBQT(pctSortList->pctFirstChild);
  1797. HRESULT hr = HrQeTreeCopy(&pctSortList->pctFirstChild,
  1798. pctProjectList->pctFirstChild);
  1799. if (FAILED(hr))
  1800. {
  1801. m_pIPTProperties->SetErrorHResult(hr, MONSQL_OUT_OF_MEMORY);
  1802. YYABORT(hr);
  1803. }
  1804. }
  1805. }
  1806. pctSortList = pctSortList->pctNextSibling;
  1807. }
  1808. m_pIPTProperties->SetSortDesc(QUERY_SORTASCEND); /* reset "stick" sort direction*/
  1809. yyval = PctCreateNode(DBOP_sort, yyvsp[-1], yyvsp[0], NULL);
  1810. }
  1811. else
  1812. {
  1813. yyval = yyvsp[-1];
  1814. }
  1815. AssertReq(yyval);
  1816. }
  1817. break;
  1818. case 28:
  1819. {
  1820. AssertReq(yyvsp[-2]); /* need a select list*/
  1821. AssertReq(yyvsp[-1]); /* need a from clause*/
  1822. if (NULL != yyvsp[-1]->pctNextSibling)
  1823. { /* the from clause is a from view*/
  1824. if (DBOP_outall_name == yyvsp[-2]->op)
  1825. {
  1826. DeleteDBQT( yyvsp[-2] );
  1827. yyvsp[-2] = yyvsp[-1];
  1828. yyvsp[-1] = yyvsp[-2]->pctNextSibling;
  1829. yyvsp[-2]->pctNextSibling = NULL;
  1830. AssertReq( yyvsp[-2]->pctFirstChild ); /* first project list element*/
  1831. DBCOMMANDTREE* pct = yyvsp[-2]->pctFirstChild;
  1832. while ( pct )
  1833. { /* recheck the properties to get current definitions*/
  1834. DeleteDBQT( pct->pctFirstChild );
  1835. pct->pctFirstChild =
  1836. PctMkColNodeFromStr( pct->value.pwszValue, m_pIPSession, m_pIPTProperties );
  1837. if ( 0 == pct->pctFirstChild )
  1838. YYABORT( DB_E_ERRORSINCOMMAND );
  1839. pct = pct->pctNextSibling;
  1840. }
  1841. }
  1842. else
  1843. {
  1844. yyvsp[-4] = yyvsp[-1];
  1845. yyvsp[-1] = yyvsp[-4]->pctNextSibling;
  1846. yyvsp[-4]->pctNextSibling = NULL;
  1847. AssertReq(yyvsp[-2]); /* project list anchor*/
  1848. AssertReq(yyvsp[-2]->pctFirstChild); /* first project list element*/
  1849. DBCOMMANDTREE* pctNewPrjLst = yyvsp[-2]->pctFirstChild;
  1850. AssertReq(yyvsp[-4]); /* project list anchor*/
  1851. AssertReq(yyvsp[-4]->pctFirstChild); /* first project list element*/
  1852. DBCOMMANDTREE* pctViewPrjLst = NULL; /* initialized within loop*/
  1853. while (pctNewPrjLst)
  1854. {
  1855. pctViewPrjLst = yyvsp[-4]->pctFirstChild;
  1856. Assert( DBOP_project_list_element == pctNewPrjLst->op );
  1857. Assert( DBVALUEKIND_WSTR == pctNewPrjLst->wKind );
  1858. while ( pctViewPrjLst )
  1859. {
  1860. Assert( DBOP_project_list_element == pctViewPrjLst->op );
  1861. Assert( DBVALUEKIND_WSTR == pctViewPrjLst->wKind );
  1862. if ( 0 == _wcsicmp(pctNewPrjLst->value.pwszValue, pctViewPrjLst->value.pwszValue) )
  1863. break;
  1864. pctViewPrjLst = pctViewPrjLst->pctNextSibling;
  1865. if ( !pctViewPrjLst )
  1866. {
  1867. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_NOT_COLUMN_OF_VIEW );
  1868. m_pIPTProperties->SetErrorToken( pctNewPrjLst->value.pwszValue );
  1869. /* UNDONE: Might want to include a view name on error message*/
  1870. YYABORT( DB_E_ERRORSINCOMMAND );
  1871. }
  1872. }
  1873. pctNewPrjLst = pctNewPrjLst->pctNextSibling;
  1874. }
  1875. DeleteDBQT( yyvsp[-4] );
  1876. yyvsp[-4] = 0;
  1877. }
  1878. }
  1879. else
  1880. {
  1881. /* "standard" from clause*/
  1882. if ( DBOP_outall_name == yyvsp[-2]->op )
  1883. if ( DBDIALECT_MSSQLJAWS != m_pIPSession->GetSQLDialect() )
  1884. {
  1885. /* SELECT * only allowed in JAWS*/
  1886. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_SELECT_STAR );
  1887. YYABORT( DB_E_ERRORSINCOMMAND );
  1888. }
  1889. else
  1890. {
  1891. yyvsp[-2] = PctCreateNode( DBOP_project_list_element, yyvsp[-2], NULL );
  1892. if ( NULL == yyvsp[-2] )
  1893. {
  1894. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  1895. YYABORT( E_OUTOFMEMORY );
  1896. }
  1897. yyvsp[-2] = PctCreateNode( DBOP_project_list_anchor, yyvsp[-2], NULL );
  1898. if ( NULL == yyvsp[-2] )
  1899. {
  1900. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  1901. YYABORT( E_OUTOFMEMORY );
  1902. }
  1903. }
  1904. }
  1905. if ( NULL != yyvsp[0] )
  1906. {
  1907. yyvsp[-4] = PctCreateNode( DBOP_select, yyvsp[-1], yyvsp[0], NULL );
  1908. if ( NULL == yyvsp[-4] )
  1909. {
  1910. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  1911. YYABORT( E_OUTOFMEMORY );
  1912. }
  1913. }
  1914. else
  1915. yyvsp[-4] = yyvsp[-1];
  1916. yyval = PctCreateNode( DBOP_project, yyvsp[-4], yyvsp[-2], NULL );
  1917. if ( NULL == yyval )
  1918. {
  1919. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  1920. YYABORT( E_OUTOFMEMORY );
  1921. }
  1922. }
  1923. break;
  1924. case 29:
  1925. {
  1926. yyval = NULL;
  1927. }
  1928. break;
  1929. case 30:
  1930. {
  1931. /* ignore ALL keyword, its just noise*/
  1932. yyval = NULL;
  1933. }
  1934. break;
  1935. case 31:
  1936. {
  1937. AssertReq(yyvsp[0]);
  1938. yyvsp[0] = PctReverse(yyvsp[0]);
  1939. yyval = PctCreateNode(DBOP_project_list_anchor, yyvsp[0], NULL);
  1940. if (NULL == yyval)
  1941. {
  1942. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1943. YYABORT(E_OUTOFMEMORY);
  1944. }
  1945. }
  1946. break;
  1947. case 32:
  1948. {
  1949. yyval = PctCreateNode(DBOP_outall_name, NULL);
  1950. if (NULL == yyval)
  1951. {
  1952. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1953. YYABORT(E_OUTOFMEMORY);
  1954. }
  1955. }
  1956. break;
  1957. case 33:
  1958. {
  1959. AssertReq(yyvsp[-2]);
  1960. AssertReq(yyvsp[0]);
  1961. /**/
  1962. /* chain project list elements together*/
  1963. /**/
  1964. yyval = PctLink( yyvsp[0], yyvsp[-2] );
  1965. if ( NULL == yyval )
  1966. {
  1967. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  1968. YYABORT(E_OUTOFMEMORY);
  1969. }
  1970. }
  1971. break;
  1972. case 35:
  1973. {
  1974. AssertReq(yyvsp[0]);
  1975. yyvsp[0]->op = DBOP_project_list_element;
  1976. yyvsp[0]->pctFirstChild = PctMkColNodeFromStr(yyvsp[0]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  1977. if (NULL == yyvsp[0]->pctFirstChild)
  1978. YYABORT(DB_E_ERRORSINCOMMAND);
  1979. yyval = yyvsp[0];
  1980. }
  1981. break;
  1982. case 36:
  1983. {
  1984. AssertReq(yyvsp[-2]);
  1985. AssertReq(yyvsp[0]);
  1986. DeleteDBQT(yyvsp[-2]); /* UNDONE: Don't use the correlation name for now*/
  1987. yyvsp[-2] = NULL;
  1988. yyvsp[0]->op = DBOP_project_list_element;
  1989. yyvsp[0]->pctFirstChild = PctMkColNodeFromStr(yyvsp[0]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  1990. if (NULL == yyvsp[0]->pctFirstChild)
  1991. YYABORT(DB_E_ERRORSINCOMMAND);
  1992. yyval = yyvsp[0];
  1993. }
  1994. break;
  1995. case 37:
  1996. {
  1997. yyval = PctMkColNodeFromStr(L"CREATE", m_pIPSession, m_pIPTProperties);
  1998. if (NULL == yyval)
  1999. YYABORT(DB_E_ERRORSINCOMMAND);
  2000. yyval = PctCreateNode(DBOP_project_list_element, DBVALUEKIND_WSTR, yyval, NULL);
  2001. yyval->value.pwszValue = CoTaskStrDup(L"CREATE");
  2002. }
  2003. break;
  2004. case 40:
  2005. {
  2006. AssertReq( yyvsp[-1] );
  2007. yyval = yyvsp[-1];
  2008. if ( NULL != yyvsp[0] )
  2009. {
  2010. yyvsp[0]->pctFirstChild = yyval;
  2011. yyval = yyvsp[0];
  2012. }
  2013. }
  2014. break;
  2015. case 41:
  2016. {
  2017. AssertReq( yyvsp[0] );
  2018. yyval = yyvsp[0];
  2019. }
  2020. break;
  2021. case 42:
  2022. {
  2023. AssertReq( yyvsp[0] );
  2024. yyval = yyvsp[0];
  2025. }
  2026. break;
  2027. case 43:
  2028. {
  2029. AssertReq( yyvsp[0] );
  2030. yyval = yyvsp[0];
  2031. }
  2032. break;
  2033. case 44:
  2034. { /* _SCOPE '(' scope_definition ')'*/
  2035. AssertReq( yyvsp[-1] );
  2036. /**/
  2037. /* Set the machine and catalog to the defaults*/
  2038. /**/
  2039. (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2040. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine )
  2041. {
  2042. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2043. YYABORT( E_OUTOFMEMORY );
  2044. }
  2045. (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2046. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog )
  2047. {
  2048. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2049. YYABORT( E_OUTOFMEMORY );
  2050. }
  2051. yyval = yyvsp[-1];
  2052. }
  2053. break;
  2054. case 45:
  2055. { /* machine_name _DOTDOTDOT_SCOPE '(' scope_definition ')'*/
  2056. AssertReq( yyvsp[-4] );
  2057. AssertReq( yyvsp[-1] );
  2058. (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-4]->value.pwszValue );
  2059. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine )
  2060. {
  2061. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2062. YYABORT( E_OUTOFMEMORY );
  2063. }
  2064. SCODE sc = m_pIPSession->GetIPVerifyPtr()->VerifyCatalog(
  2065. yyvsp[-4]->value.pwszValue,
  2066. m_pIPSession->GetDefaultCatalog() );
  2067. if ( S_OK != sc )
  2068. {
  2069. m_pIPTProperties->SetErrorHResult( sc, MONSQL_INVALID_CATALOG );
  2070. m_pIPTProperties->SetErrorToken( m_pIPSession->GetDefaultCatalog() );
  2071. YYABORT( sc );
  2072. }
  2073. (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2074. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog )
  2075. {
  2076. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2077. YYABORT( E_OUTOFMEMORY );
  2078. }
  2079. DeleteDBQT( yyvsp[-4] );
  2080. yyval = yyvsp[-1];
  2081. }
  2082. break;
  2083. case 46:
  2084. { /* machine_name _DOT catalog_name _DOTDOT_SCOPE '(' scope_definition ')'*/
  2085. AssertReq( yyvsp[-6] );
  2086. AssertReq( yyvsp[-4] );
  2087. AssertReq( yyvsp[-1] );
  2088. (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-6]->value.pwszValue );
  2089. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine )
  2090. {
  2091. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2092. YYABORT( E_OUTOFMEMORY );
  2093. }
  2094. /**/
  2095. /* Verify catalog on machine specified*/
  2096. /**/
  2097. SCODE sc = m_pIPSession->GetIPVerifyPtr()->VerifyCatalog(
  2098. yyvsp[-6]->value.pwszValue,
  2099. yyvsp[-4]->value.pwszValue );
  2100. if ( S_OK != sc )
  2101. {
  2102. m_pIPTProperties->SetErrorHResult( sc, MONSQL_INVALID_CATALOG );
  2103. m_pIPTProperties->SetErrorToken( yyvsp[-4]->value.pwszValue );
  2104. YYABORT( sc );
  2105. }
  2106. (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-4]->value.pwszValue );
  2107. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog )
  2108. {
  2109. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2110. YYABORT( E_OUTOFMEMORY );
  2111. }
  2112. DeleteDBQT( yyvsp[-6] );
  2113. DeleteDBQT( yyvsp[-4] );
  2114. yyval = yyvsp[-1];
  2115. }
  2116. break;
  2117. case 47:
  2118. { /* catalog_name _DOTDOT_SCOPE '(' scope_definition ')'*/
  2119. AssertReq( yyvsp[-4] );
  2120. AssertReq( yyvsp[-1] );
  2121. (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2122. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszMachine )
  2123. {
  2124. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2125. YYABORT( E_OUTOFMEMORY );
  2126. }
  2127. /**/
  2128. /* See if catalog is valid on default machine*/
  2129. /**/
  2130. SCODE sc = m_pIPSession->GetIPVerifyPtr()->VerifyCatalog(
  2131. m_pIPSession->GetDefaultMachine(),
  2132. yyvsp[-4]->value.pwszValue );
  2133. if ( S_OK != sc )
  2134. {
  2135. m_pIPTProperties->SetErrorHResult( sc, MONSQL_INVALID_CATALOG );
  2136. m_pIPTProperties->SetErrorToken( yyvsp[-4]->value.pwszValue );
  2137. YYABORT( sc );
  2138. }
  2139. (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-4]->value.pwszValue );
  2140. if ( NULL == (yyvsp[-1]->value.pdbcntnttblValue)->pwszCatalog )
  2141. {
  2142. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2143. YYABORT( E_OUTOFMEMORY );
  2144. }
  2145. DeleteDBQT( yyvsp[-4] );
  2146. yyval = yyvsp[-1];
  2147. }
  2148. break;
  2149. case 48:
  2150. {
  2151. AssertReq( yyvsp[0] );
  2152. yyval = yyvsp[0];
  2153. }
  2154. break;
  2155. case 49:
  2156. {
  2157. AssertReq( yyvsp[0] );
  2158. /**/
  2159. /* Defer validation of the catalog to the point where we*/
  2160. /* know the machine name. Return whatever was parsed here.*/
  2161. /**/
  2162. yyval = yyvsp[0];
  2163. }
  2164. break;
  2165. case 50:
  2166. { /* empty rule for scope_definition*/
  2167. /**/
  2168. /* Create a DBOP_content_table node with default scope settings*/
  2169. /**/
  2170. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2171. if ( NULL == yyval )
  2172. {
  2173. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND,
  2174. MONSQL_OUT_OF_MEMORY );
  2175. YYABORT( E_OUTOFMEMORY );
  2176. }
  2177. }
  2178. break;
  2179. case 51:
  2180. { /* scope_element_list*/
  2181. AssertReq(yyvsp[0]);
  2182. yyvsp[0] = PctReverse( yyvsp[0] );
  2183. yyval = PctCreateNode( DBOP_scope_list_anchor, yyvsp[0], NULL );
  2184. if ( NULL == yyval )
  2185. {
  2186. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2187. YYABORT( E_OUTOFMEMORY );
  2188. }
  2189. yyval = PctCreateNode( DBOP_content_table, DBVALUEKIND_CONTENTTABLE, yyval, NULL );
  2190. if ( NULL == yyval )
  2191. {
  2192. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2193. YYABORT( E_OUTOFMEMORY );
  2194. }
  2195. }
  2196. break;
  2197. case 52:
  2198. {
  2199. AssertReq( yyvsp[-2] );
  2200. AssertReq( yyvsp[0]);
  2201. /**/
  2202. /* chain scope list elements together*/
  2203. /**/
  2204. yyval = PctLink( yyvsp[0], yyvsp[-2] );
  2205. }
  2206. break;
  2207. case 53:
  2208. {
  2209. AssertReq( yyvsp[0] );
  2210. yyval = yyvsp[0];
  2211. }
  2212. break;
  2213. case 54:
  2214. {
  2215. AssertReq( yyvsp[-2] );
  2216. AssertReq( yyvsp[-1] );
  2217. yyvsp[-1] = PctReverse( yyvsp[-1] );
  2218. SetDepthAndInclusion( yyvsp[-2], yyvsp[-1] );
  2219. DeleteDBQT( yyvsp[-2] );
  2220. yyval = yyvsp[-1];
  2221. }
  2222. break;
  2223. case 55:
  2224. {
  2225. AssertReq( yyvsp[-4] );
  2226. AssertReq( yyvsp[-2] );
  2227. yyvsp[-2] = PctReverse( yyvsp[-2] );
  2228. SetDepthAndInclusion( yyvsp[-4], yyvsp[-2] );
  2229. DeleteDBQT( yyvsp[-4] );
  2230. yyval = yyvsp[-2];
  2231. }
  2232. break;
  2233. case 56:
  2234. {
  2235. yyval = PctAllocNode( DBVALUEKIND_CONTENTSCOPE, DBOP_scope_list_element );
  2236. if ( NULL == yyval )
  2237. {
  2238. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2239. YYABORT( E_OUTOFMEMORY );
  2240. }
  2241. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_FLAG_DEEP;
  2242. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_FLAG_INCLUDE;
  2243. }
  2244. break;
  2245. case 57:
  2246. {
  2247. yyval = PctAllocNode( DBVALUEKIND_CONTENTSCOPE, DBOP_scope_list_element );
  2248. if ( NULL == yyval )
  2249. {
  2250. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2251. YYABORT( E_OUTOFMEMORY );
  2252. }
  2253. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_FLAG_DEEP;
  2254. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_FLAG_INCLUDE;
  2255. }
  2256. break;
  2257. case 58:
  2258. {
  2259. yyval = PctAllocNode( DBVALUEKIND_CONTENTSCOPE, DBOP_scope_list_element );
  2260. if ( NULL == yyval )
  2261. {
  2262. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2263. YYABORT( E_OUTOFMEMORY );
  2264. }
  2265. yyval->value.pdbcntntscpValue->dwFlags &= ~(SCOPE_FLAG_DEEP);
  2266. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_FLAG_INCLUDE;
  2267. }
  2268. break;
  2269. case 59:
  2270. {
  2271. AssertReq( yyvsp[-2] );
  2272. AssertReq( yyvsp[0] );
  2273. /**/
  2274. /* chain path/vpath nodes together*/
  2275. /**/
  2276. yyval = PctLink( yyvsp[0], yyvsp[-2] );
  2277. }
  2278. break;
  2279. case 60:
  2280. {
  2281. AssertReq( yyvsp[0] );
  2282. yyval = yyvsp[0];
  2283. }
  2284. break;
  2285. case 61:
  2286. {
  2287. AssertReq( yyvsp[0] );
  2288. yyval = PctAllocNode( DBVALUEKIND_CONTENTSCOPE, DBOP_scope_list_element );
  2289. if ( NULL == yyval )
  2290. {
  2291. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND,
  2292. MONSQL_OUT_OF_MEMORY );
  2293. YYABORT( E_OUTOFMEMORY );
  2294. }
  2295. yyval->value.pdbcntntscpValue->pwszElementValue =
  2296. CoTaskStrDup( (yyvsp[0]->value.pvarValue)->bstrVal );
  2297. if ( NULL == yyval->value.pdbcntntscpValue->pwszElementValue )
  2298. {
  2299. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND,
  2300. MONSQL_OUT_OF_MEMORY );
  2301. YYABORT( E_OUTOFMEMORY );
  2302. }
  2303. if ( NULL != wcschr(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal, L'/'))
  2304. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_TYPE_VPATH;
  2305. else
  2306. yyval->value.pdbcntntscpValue->dwFlags |= SCOPE_TYPE_WINPATH;
  2307. /**/
  2308. /* Path names need backlashes not forward slashes*/
  2309. /**/
  2310. for (WCHAR *wcsLetter = yyval->value.pdbcntntscpValue->pwszElementValue;
  2311. *wcsLetter != L'\0';
  2312. wcsLetter++)
  2313. if (L'/' == *wcsLetter)
  2314. *wcsLetter = L'\\';
  2315. DeleteDBQT( yyvsp[0] );
  2316. }
  2317. break;
  2318. case 62:
  2319. {
  2320. yyval = NULL;
  2321. }
  2322. break;
  2323. case 63:
  2324. {
  2325. AssertReq(yyvsp[0]);
  2326. /* $2->op = DBOP_alias; // retag _ID node to be table alias*/
  2327. /* $$ = $2; // UNDONE: This doesn't work with Index Server*/
  2328. DeleteDBQT(yyvsp[0]);
  2329. yyvsp[0] = NULL;
  2330. yyval = NULL;
  2331. }
  2332. break;
  2333. case 64:
  2334. { /* _FROM view_name*/
  2335. AssertReq( yyvsp[0] );
  2336. /* node telling where the view is defined*/
  2337. Assert( DBOP_content_table == yyvsp[0]->op );
  2338. /* name of the view*/
  2339. AssertReq( yyvsp[0]->pctNextSibling );
  2340. yyval = m_pIPSession->GetLocalViewList()->GetViewDefinition( m_pIPTProperties,
  2341. yyvsp[0]->pctNextSibling->value.pwszValue,
  2342. (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  2343. if ( 0 == yyval )
  2344. yyval = m_pIPSession->GetGlobalViewList()->GetViewDefinition( m_pIPTProperties,
  2345. yyvsp[0]->pctNextSibling->value.pwszValue,
  2346. (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  2347. if ( 0 == yyval )
  2348. { /* If this isn't JAWS, this is an undefined view*/
  2349. if (DBDIALECT_MSSQLJAWS != m_pIPSession->GetSQLDialect())
  2350. {
  2351. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_VIEW_NOT_DEFINED );
  2352. m_pIPTProperties->SetErrorToken( yyvsp[0]->pctNextSibling->value.pwszValue );
  2353. m_pIPTProperties->SetErrorToken( (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  2354. YYABORT( DB_E_ERRORSINCOMMAND );
  2355. }
  2356. /* setting the default scope for JAWS*/
  2357. CScopeData* pScopeData = m_pIPTProperties->GetScopeDataPtr();
  2358. pScopeData->SetTemporaryDepth(QUERY_DEEP);
  2359. pScopeData->MaskTemporaryDepth(QUERY_VIRTUAL_PATH);
  2360. pScopeData->SetTemporaryScope(VAL_AND_CCH_MINUS_NULL(L"/"));
  2361. pScopeData->SetTemporaryCatalog(yyvsp[0]->value.pwszValue, wcslen(yyvsp[0]->value.pwszValue));
  2362. pScopeData->IncrementScopeCount();
  2363. yyval = yyvsp[0]->pctNextSibling;
  2364. yyvsp[0]->pctNextSibling = NULL;
  2365. DeleteDBQT(yyvsp[0]);
  2366. }
  2367. else /* actually a view name*/
  2368. {
  2369. /* If we didn't store scope information (global views), set up the scope now*/
  2370. if ( 0 == yyval->pctNextSibling )
  2371. {
  2372. /* name of the view*/
  2373. DeleteDBQT( yyvsp[0]->pctNextSibling );
  2374. yyvsp[0]->pctNextSibling = 0;
  2375. yyval->pctNextSibling = yyvsp[0];
  2376. }
  2377. else
  2378. {
  2379. AssertReq( DBOP_content_table == yyval->pctNextSibling->op );
  2380. DeleteDBQT( yyvsp[0] ); /* throw away the view name*/
  2381. }
  2382. }
  2383. }
  2384. break;
  2385. case 65:
  2386. { /* _TEMPVIEW*/
  2387. AssertReq( yyvsp[0] );
  2388. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2389. if ( 0 == yyval )
  2390. {
  2391. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2392. YYABORT( E_OUTOFMEMORY );
  2393. }
  2394. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2395. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2396. {
  2397. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2398. YYABORT( E_OUTOFMEMORY );
  2399. }
  2400. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2401. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2402. {
  2403. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2404. YYABORT( E_OUTOFMEMORY );
  2405. }
  2406. yyval->pctNextSibling = yyvsp[0];
  2407. }
  2408. break;
  2409. case 66:
  2410. { /* identifier*/
  2411. AssertReq( yyvsp[0] );
  2412. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2413. if ( 0 == yyval )
  2414. {
  2415. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2416. YYABORT( E_OUTOFMEMORY );
  2417. }
  2418. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2419. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2420. {
  2421. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2422. YYABORT( E_OUTOFMEMORY );
  2423. }
  2424. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2425. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2426. {
  2427. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2428. YYABORT( E_OUTOFMEMORY );
  2429. }
  2430. yyval->pctNextSibling = yyvsp[0];
  2431. }
  2432. break;
  2433. case 67:
  2434. { /* catalog_name _DOTDOT _TEMPVIEW*/
  2435. AssertReq(yyvsp[-2]);
  2436. AssertReq(yyvsp[0]);
  2437. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2438. if ( 0 == yyval )
  2439. {
  2440. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2441. YYABORT( E_OUTOFMEMORY );
  2442. }
  2443. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2444. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2445. {
  2446. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2447. YYABORT( E_OUTOFMEMORY );
  2448. }
  2449. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2450. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2451. {
  2452. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2453. YYABORT( E_OUTOFMEMORY );
  2454. }
  2455. DeleteDBQT( yyvsp[-2] );
  2456. yyval->pctNextSibling = yyvsp[0];
  2457. }
  2458. break;
  2459. case 68:
  2460. { /* catalog_name _DOTDOT identifier*/
  2461. AssertReq(yyvsp[-2]);
  2462. AssertReq(yyvsp[0]);
  2463. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2464. if ( 0 == yyval )
  2465. {
  2466. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2467. YYABORT( E_OUTOFMEMORY );
  2468. }
  2469. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( m_pIPSession->GetDefaultMachine() );
  2470. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2471. {
  2472. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2473. YYABORT( E_OUTOFMEMORY );
  2474. }
  2475. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2476. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2477. {
  2478. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2479. YYABORT( E_OUTOFMEMORY );
  2480. }
  2481. DeleteDBQT( yyvsp[-2] );
  2482. yyval->pctNextSibling = yyvsp[0];
  2483. }
  2484. break;
  2485. case 69:
  2486. { /* machine_name _DOT catalog_name _DOTDOT _TEMPVIEW*/
  2487. AssertReq( yyvsp[-4] );
  2488. AssertReq( yyvsp[-2] );
  2489. AssertReq( yyvsp[0] );
  2490. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2491. if ( 0 == yyval )
  2492. {
  2493. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2494. YYABORT( E_OUTOFMEMORY );
  2495. }
  2496. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-4]->value.pwszValue );
  2497. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2498. {
  2499. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2500. YYABORT( E_OUTOFMEMORY );
  2501. }
  2502. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2503. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2504. {
  2505. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2506. YYABORT( E_OUTOFMEMORY );
  2507. }
  2508. DeleteDBQT( yyvsp[-4] );
  2509. DeleteDBQT( yyvsp[-2] );
  2510. yyval->pctNextSibling = yyvsp[0];
  2511. }
  2512. break;
  2513. case 70:
  2514. { /* machine_name _DOT catalog_name _DOTDOT identifier*/
  2515. AssertReq( yyvsp[-4] );
  2516. AssertReq( yyvsp[-2] );
  2517. AssertReq( yyvsp[0] );
  2518. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2519. if ( 0 == yyval )
  2520. {
  2521. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2522. YYABORT( E_OUTOFMEMORY );
  2523. }
  2524. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-4]->value.pwszValue );
  2525. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2526. {
  2527. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2528. YYABORT( E_OUTOFMEMORY );
  2529. }
  2530. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2531. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2532. {
  2533. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2534. YYABORT( E_OUTOFMEMORY );
  2535. }
  2536. DeleteDBQT( yyvsp[-4] );
  2537. DeleteDBQT( yyvsp[-2] );
  2538. yyval->pctNextSibling = yyvsp[0];
  2539. }
  2540. break;
  2541. case 71:
  2542. { /* machine_name _DOTDOTDOT identifier*/
  2543. AssertReq( yyvsp[-2] );
  2544. AssertReq( yyvsp[0] );
  2545. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2546. if ( 0 == yyval )
  2547. {
  2548. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2549. YYABORT( E_OUTOFMEMORY );
  2550. }
  2551. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2552. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2553. {
  2554. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2555. YYABORT( E_OUTOFMEMORY );
  2556. }
  2557. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2558. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2559. {
  2560. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2561. YYABORT( E_OUTOFMEMORY );
  2562. }
  2563. DeleteDBQT( yyvsp[-2] );
  2564. yyval->pctNextSibling = yyvsp[0];
  2565. }
  2566. break;
  2567. case 72:
  2568. { /* machine_name _DOTDOTDOT _TEMPVIEW*/
  2569. AssertReq( yyvsp[-2] );
  2570. AssertReq( yyvsp[0] );
  2571. yyval = PctAllocNode( DBVALUEKIND_CONTENTTABLE, DBOP_content_table );
  2572. if ( 0 == yyval )
  2573. {
  2574. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2575. YYABORT( E_OUTOFMEMORY );
  2576. }
  2577. (yyval->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( yyvsp[-2]->value.pwszValue );
  2578. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszMachine )
  2579. {
  2580. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2581. YYABORT( E_OUTOFMEMORY );
  2582. }
  2583. (yyval->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( m_pIPSession->GetDefaultCatalog() );
  2584. if ( 0 == (yyval->value.pdbcntnttblValue)->pwszCatalog )
  2585. {
  2586. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  2587. YYABORT( E_OUTOFMEMORY );
  2588. }
  2589. DeleteDBQT( yyvsp[-2] );
  2590. yyval->pctNextSibling = yyvsp[0];
  2591. }
  2592. break;
  2593. case 73:
  2594. {
  2595. yyval = yyvsp[-1];
  2596. }
  2597. break;
  2598. case 74:
  2599. {
  2600. AssertReq( yyvsp[-3] );
  2601. AssertReq( yyvsp[0] );
  2602. yyval = PctCreateNode( DBOP_set_union, yyvsp[-3], yyvsp[0], NULL );
  2603. if ( NULL == yyval )
  2604. {
  2605. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND,
  2606. MONSQL_OUT_OF_MEMORY );
  2607. YYABORT( E_OUTOFMEMORY );
  2608. }
  2609. }
  2610. break;
  2611. case 75:
  2612. {
  2613. AssertReq( yyvsp[-3] );
  2614. AssertReq( yyvsp[0] );
  2615. yyval = PctCreateNode( DBOP_set_union, yyvsp[-3], yyvsp[0], NULL );
  2616. if ( NULL == yyval )
  2617. {
  2618. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND,
  2619. MONSQL_OUT_OF_MEMORY );
  2620. YYABORT( E_OUTOFMEMORY );
  2621. }
  2622. }
  2623. break;
  2624. case 76:
  2625. {
  2626. AssertReq( yyvsp[0] );
  2627. yyval = yyvsp[0];
  2628. }
  2629. break;
  2630. case 77:
  2631. {
  2632. yyval = NULL;
  2633. }
  2634. break;
  2635. case 79:
  2636. {
  2637. AssertReq(yyvsp[0]);
  2638. yyval = yyvsp[0];
  2639. }
  2640. break;
  2641. case 80:
  2642. {
  2643. AssertReq(yyvsp[-1]);
  2644. if (wcslen(((PROPVARIANT*)yyvsp[-1]->value.pvValue)->bstrVal))
  2645. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[-1]->value.pvValue)->bstrVal,
  2646. wcslen(((PROPVARIANT*)yyvsp[-1]->value.pvValue)->bstrVal));
  2647. UINT cSize = 0;
  2648. CIPROPERTYDEF* pPropTable = m_pIPSession->m_pCPropertyList->GetPropertyTable(&cSize);
  2649. if (!pPropTable)
  2650. {
  2651. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2652. YYABORT(E_OUTOFMEMORY);
  2653. }
  2654. if (FAILED(CITextToSelectTreeEx(((PROPVARIANT*)yyvsp[-1]->value.pvValue)->bstrVal,
  2655. ISQLANG_V2,
  2656. &yyval,
  2657. cSize,
  2658. pPropTable,
  2659. m_pIPSession->GetLCID())))
  2660. {
  2661. m_pIPSession->m_pCPropertyList->DeletePropertyTable(pPropTable, cSize);
  2662. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_CITEXTTOSELECTTREE_FAILED);
  2663. m_pIPTProperties->SetErrorToken(((PROPVARIANT*)yyvsp[-1]->value.pvValue)->bstrVal);
  2664. YYABORT(DB_E_ERRORSINCOMMAND);
  2665. }
  2666. DeleteDBQT(yyvsp[-1]);
  2667. yyvsp[-1] = NULL;
  2668. m_pIPSession->m_pCPropertyList->DeletePropertyTable(pPropTable, cSize);
  2669. }
  2670. break;
  2671. case 88:
  2672. {
  2673. AssertReq(yyvsp[-2]);
  2674. AssertReq(yyvsp[-1]);
  2675. if (m_pIPTProperties->GetDBType() & DBTYPE_VECTOR)
  2676. {
  2677. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  2678. m_pIPTProperties->SetErrorToken(L"<literal>");
  2679. m_pIPTProperties->SetErrorToken(L"ARRAY");
  2680. YYABORT(DB_E_ERRORSINCOMMAND);
  2681. }
  2682. yyvsp[-2]->pctNextSibling = yyvsp[0];
  2683. yyvsp[-1]->pctFirstChild = yyvsp[-2];
  2684. yyval = yyvsp[-1];
  2685. }
  2686. break;
  2687. case 89:
  2688. {
  2689. AssertReq(yyvsp[0]);
  2690. m_pIPTProperties->UseCiColumn(L'@');
  2691. yyval = yyvsp[0];
  2692. }
  2693. break;
  2694. case 90:
  2695. {
  2696. AssertReq(yyvsp[-3]);
  2697. AssertReq(yyvsp[-1]);
  2698. if (DBDIALECT_MSSQLJAWS != m_pIPSession->GetSQLDialect())
  2699. {
  2700. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  2701. m_pIPTProperties->SetErrorToken(L"CAST");
  2702. m_pIPTProperties->SetErrorToken(L"column_reference");
  2703. YYABORT(DB_E_ERRORSINCOMMAND);
  2704. }
  2705. m_pIPTProperties->UseCiColumn(L'@');
  2706. m_pIPTProperties->SetDBType(yyvsp[-1]->value.usValue);
  2707. DeleteDBQT(yyvsp[-1]);
  2708. yyval = yyvsp[-3];
  2709. }
  2710. break;
  2711. case 91:
  2712. {
  2713. AssertReq(yyvsp[0]);
  2714. yyval = PctMkColNodeFromStr(yyvsp[0]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  2715. if (NULL == yyval)
  2716. YYABORT(DB_E_ERRORSINCOMMAND);
  2717. m_pIPTProperties->SetCiColumn(yyvsp[0]->value.pwszValue);
  2718. DeleteDBQT(yyvsp[0]);
  2719. yyvsp[0] = NULL;
  2720. }
  2721. break;
  2722. case 92:
  2723. {
  2724. AssertReq(yyvsp[-2]);
  2725. AssertReq(yyvsp[0]);
  2726. yyval = PctMkColNodeFromStr(yyvsp[0]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  2727. if (NULL == yyval)
  2728. YYABORT(DB_E_ERRORSINCOMMAND);
  2729. m_pIPTProperties->SetCiColumn(yyvsp[0]->value.pwszValue);
  2730. DeleteDBQT(yyvsp[0]);
  2731. yyvsp[0] = NULL;
  2732. DeleteDBQT(yyvsp[-2]); /* UNDONE: Don't use the correlation name for now*/
  2733. yyvsp[-2] = NULL;
  2734. }
  2735. break;
  2736. case 93:
  2737. {
  2738. m_pIPTProperties->SetCiColumn(L"CREATE");
  2739. yyval = PctMkColNodeFromStr(L"CREATE", m_pIPSession, m_pIPTProperties);
  2740. if (NULL == yyval)
  2741. YYABORT(DB_E_ERRORSINCOMMAND);
  2742. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"CREATE "));
  2743. }
  2744. break;
  2745. case 94:
  2746. {
  2747. yyval = PctCreateRelationalNode(DBOP_equal, DEFAULTWEIGHT);
  2748. if (NULL == yyval)
  2749. {
  2750. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2751. YYABORT(E_OUTOFMEMORY);
  2752. }
  2753. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"="));
  2754. }
  2755. break;
  2756. case 95:
  2757. {
  2758. yyval = PctCreateRelationalNode(DBOP_not_equal, DEFAULTWEIGHT);
  2759. if (NULL == yyval)
  2760. {
  2761. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2762. YYABORT(E_OUTOFMEMORY);
  2763. }
  2764. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"!="));
  2765. }
  2766. break;
  2767. case 96:
  2768. {
  2769. yyval = PctCreateRelationalNode(DBOP_less, DEFAULTWEIGHT);
  2770. if (NULL == yyval)
  2771. {
  2772. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2773. YYABORT(E_OUTOFMEMORY);
  2774. }
  2775. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"<"));
  2776. }
  2777. break;
  2778. case 97:
  2779. {
  2780. yyval = PctCreateRelationalNode(DBOP_greater, DEFAULTWEIGHT);
  2781. if (NULL == yyval)
  2782. {
  2783. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2784. YYABORT(E_OUTOFMEMORY);
  2785. }
  2786. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L">"));
  2787. }
  2788. break;
  2789. case 98:
  2790. {
  2791. yyval = PctCreateRelationalNode(DBOP_less_equal, DEFAULTWEIGHT);
  2792. if (NULL == yyval)
  2793. {
  2794. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2795. YYABORT(E_OUTOFMEMORY);
  2796. }
  2797. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"<="));
  2798. }
  2799. break;
  2800. case 99:
  2801. {
  2802. yyval = PctCreateRelationalNode(DBOP_greater_equal, DEFAULTWEIGHT);
  2803. if (NULL == yyval)
  2804. {
  2805. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2806. YYABORT(E_OUTOFMEMORY);
  2807. }
  2808. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L">="));
  2809. }
  2810. break;
  2811. case 100:
  2812. {
  2813. AssertReq(!yyvsp[-5]); /* should have been NULLed out in opt_contents_column_reference*/
  2814. AssertReq(yyvsp[-3]);
  2815. yyval = yyvsp[-3];
  2816. DeleteDBQT(m_pIPTProperties->GetContainsColumn());
  2817. m_pIPTProperties->SetContainsColumn(NULL);
  2818. }
  2819. break;
  2820. case 101:
  2821. { /* opt_contents_column_reference empty rule*/
  2822. yyval = PctMkColNodeFromStr(L"CONTENTS", m_pIPSession, m_pIPTProperties);
  2823. if (NULL == yyval)
  2824. YYABORT(DB_E_ERRORSINCOMMAND);
  2825. m_pIPTProperties->SetCiColumn(L"CONTENTS");
  2826. m_pIPTProperties->SetContainsColumn(yyval);
  2827. yyval = NULL;
  2828. }
  2829. break;
  2830. case 102:
  2831. { /* column_reference ','*/
  2832. m_pIPTProperties->SetContainsColumn(yyvsp[-1]);
  2833. yyval = NULL;
  2834. }
  2835. break;
  2836. case 103:
  2837. {
  2838. /* This forces a left parentheses before the content search condition*/
  2839. /* The matching right paren will be added below.*/
  2840. m_pIPTProperties->CiNeedLeftParen();
  2841. yyval = NULL;
  2842. }
  2843. break;
  2844. case 104:
  2845. {
  2846. AssertReq(yyvsp[0]);
  2847. yyval = yyvsp[0];
  2848. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L")"));
  2849. }
  2850. break;
  2851. case 106:
  2852. {
  2853. if (DBOP_not == yyvsp[0]->op)
  2854. {
  2855. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OR_NOT);
  2856. YYABORT(DB_E_ERRORSINCOMMAND);
  2857. }
  2858. yyval = PctCreateBooleanNode(DBOP_or, DEFAULTWEIGHT, yyvsp[-2], yyvsp[0]);
  2859. if (NULL == yyval)
  2860. {
  2861. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2862. YYABORT(E_OUTOFMEMORY);
  2863. }
  2864. }
  2865. break;
  2866. case 108:
  2867. {
  2868. yyval = PctCreateBooleanNode(DBOP_and, DEFAULTWEIGHT, yyvsp[-2], yyvsp[0]);
  2869. if (NULL == yyval)
  2870. {
  2871. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2872. YYABORT(E_OUTOFMEMORY);
  2873. }
  2874. }
  2875. break;
  2876. case 110:
  2877. {
  2878. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[0]);
  2879. if (NULL == yyval)
  2880. {
  2881. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2882. YYABORT(E_OUTOFMEMORY);
  2883. }
  2884. }
  2885. break;
  2886. case 112:
  2887. {
  2888. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"("));
  2889. }
  2890. break;
  2891. case 113:
  2892. {
  2893. AssertReq(yyvsp[-1]);
  2894. yyval = yyvsp[-1];
  2895. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L")"));
  2896. }
  2897. break;
  2898. case 119:
  2899. {
  2900. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" | "));
  2901. }
  2902. break;
  2903. case 120:
  2904. {
  2905. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" | "));
  2906. }
  2907. break;
  2908. case 121:
  2909. {
  2910. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" & "));
  2911. }
  2912. break;
  2913. case 122:
  2914. {
  2915. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" & "));
  2916. }
  2917. break;
  2918. case 123:
  2919. {
  2920. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ! "));
  2921. }
  2922. break;
  2923. case 124:
  2924. {
  2925. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ! "));
  2926. }
  2927. break;
  2928. case 125:
  2929. {
  2930. AssertReq(yyvsp[0]);
  2931. HRESULT hr = HrQeTreeCopy(&yyval, m_pIPTProperties->GetContainsColumn());
  2932. if (FAILED(hr))
  2933. {
  2934. m_pIPTProperties->SetErrorHResult(hr, MONSQL_OUT_OF_MEMORY);
  2935. YYABORT(hr);
  2936. }
  2937. m_pIPTProperties->UseCiColumn(L'@');
  2938. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  2939. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal,
  2940. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal));
  2941. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  2942. yyval = PctCreateContentNode(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal, GENERATE_METHOD_EXACT,
  2943. DEFAULTWEIGHT, m_pIPSession->GetLCID(), yyval);
  2944. if (NULL == yyval)
  2945. {
  2946. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2947. YYABORT(E_OUTOFMEMORY);
  2948. }
  2949. DeleteDBQT(yyvsp[0]);
  2950. yyvsp[0] = NULL;
  2951. }
  2952. break;
  2953. case 126:
  2954. {
  2955. AssertReq(yyvsp[0]);
  2956. Assert(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[wcslen(
  2957. ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal)-1] == L'*');
  2958. m_pIPTProperties->UseCiColumn(L'@');
  2959. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal,
  2960. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal));
  2961. ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[wcslen(
  2962. ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal)-1] = L'\0';
  2963. HRESULT hr = HrQeTreeCopy(&yyval, m_pIPTProperties->GetContainsColumn());
  2964. if (FAILED(hr))
  2965. {
  2966. m_pIPTProperties->SetErrorHResult(hr, MONSQL_OUT_OF_MEMORY);
  2967. YYABORT(hr);
  2968. }
  2969. yyval = PctCreateContentNode(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal, GENERATE_METHOD_PREFIX,
  2970. DEFAULTWEIGHT, m_pIPSession->GetLCID(), yyval);
  2971. if (NULL == yyval)
  2972. {
  2973. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2974. YYABORT(E_OUTOFMEMORY);
  2975. }
  2976. DeleteDBQT(yyvsp[0]);
  2977. yyvsp[0] = NULL;
  2978. }
  2979. break;
  2980. case 127:
  2981. {
  2982. AssertReq(yyvsp[-1]);
  2983. AssertReq(yyvsp[0]);
  2984. yyvsp[0] = PctReverse(yyvsp[0]);
  2985. yyval = PctCreateNode(DBOP_content_proximity, DBVALUEKIND_CONTENTPROXIMITY, yyvsp[-1], yyvsp[0], NULL);
  2986. if (NULL == yyval)
  2987. {
  2988. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  2989. YYABORT(E_OUTOFMEMORY);
  2990. }
  2991. yyval->value.pdbcntntproxValue->dwProximityUnit = PROXIMITY_UNIT_WORD;
  2992. yyval->value.pdbcntntproxValue->ulProximityDistance = 50;
  2993. yyval->value.pdbcntntproxValue->lWeight = DEFAULTWEIGHT;
  2994. }
  2995. break;
  2996. case 128:
  2997. {
  2998. AssertReq(yyvsp[-1]);
  2999. AssertReq(yyvsp[0]);
  3000. yyval = PctLink(yyvsp[0], yyvsp[-1]);
  3001. if (NULL == yyval)
  3002. {
  3003. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3004. YYABORT(E_OUTOFMEMORY);
  3005. }
  3006. }
  3007. break;
  3008. case 130:
  3009. {
  3010. AssertReq(yyvsp[0]);
  3011. yyval = yyvsp[0]; /* UNDONE: What is proximity_specification good for?*/
  3012. }
  3013. break;
  3014. case 133:
  3015. {
  3016. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ~ "));
  3017. }
  3018. break;
  3019. case 134:
  3020. {
  3021. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ~ "));
  3022. }
  3023. break;
  3024. case 135:
  3025. {
  3026. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ~ "));
  3027. }
  3028. break;
  3029. case 136:
  3030. {
  3031. AssertReq(yyvsp[-1]);
  3032. /* UNDONE: Should make use of $3 somewhere in here*/
  3033. yyval = yyvsp[-1];
  3034. }
  3035. break;
  3036. case 137:
  3037. {
  3038. if (0 == _wcsicmp(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal, L"INFLECTIONAL"))
  3039. {
  3040. DeleteDBQT(yyvsp[0]);
  3041. yyvsp[0] = NULL;
  3042. yyval = NULL;
  3043. }
  3044. /* *************************************NOT IMPLEMENTED BY INDEX SERVER **************************************
  3045. else if (0 == _wcsicmp(((PROPVARIANT*)$1->value.pvValue)->bstrVal, L"DERIVATIONAL"))
  3046. {
  3047. m_pIPTProperties->SetErrorHResult(E_NOTIMPL, MONSQL_PARSE_ERROR);
  3048. m_pIPTProperties->SetErrorToken(L"DERIVATIONAL");
  3049. YYABORT(E_NOTIMPL);
  3050. }
  3051. else if (0 == _wcsicmp(((PROPVARIANT*)$1->value.pvValue)->bstrVal, L"SOUNDEX"))
  3052. {
  3053. m_pIPTProperties->SetErrorHResult(E_NOTIMPL, MONSQL_PARSE_ERROR);
  3054. m_pIPTProperties->SetErrorToken(L"DERIVATIONAL");
  3055. YYABORT(E_NOTIMPL);
  3056. }
  3057. else if (0 == _wcsicmp(((PROPVARIANT*)$1->value.pvValue)->bstrVal, L"THESAURUS"))
  3058. {
  3059. m_pIPTProperties->SetErrorHResult(E_NOTIMPL, MONSQL_PARSE_ERROR);
  3060. m_pIPTProperties->SetErrorToken(L"THESAURUS");
  3061. YYABORT(E_NOTIMPL);
  3062. }
  3063. *************************************NOT IMPLEMENTED BY INDEX SERVER ************************************** */
  3064. else
  3065. {
  3066. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  3067. m_pIPTProperties->SetErrorToken(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal);
  3068. m_pIPTProperties->SetErrorToken(L"INFLECTIONAL");
  3069. YYABORT(E_NOTIMPL);
  3070. }
  3071. }
  3072. break;
  3073. case 138:
  3074. {
  3075. AssertReq(yyvsp[-2]);
  3076. AssertReq(yyvsp[0]);
  3077. Assert(DBOP_content == yyvsp[0]->op);
  3078. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"**"));
  3079. yyvsp[0]->value.pdbcntntValue->dwGenerateMethod = GENERATE_METHOD_INFLECT;
  3080. yyval = PctCreateBooleanNode(DBOP_or, DEFAULTWEIGHT, yyvsp[-2], yyvsp[0]);
  3081. if (NULL == yyval)
  3082. {
  3083. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3084. YYABORT(E_OUTOFMEMORY);
  3085. }
  3086. }
  3087. break;
  3088. case 139:
  3089. {
  3090. AssertReq(yyvsp[0]);
  3091. Assert(DBOP_content == yyvsp[0]->op);
  3092. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"**"));
  3093. yyvsp[0]->value.pdbcntntValue->dwGenerateMethod = GENERATE_METHOD_INFLECT;
  3094. yyval = yyvsp[0];
  3095. }
  3096. break;
  3097. case 140:
  3098. {
  3099. AssertReq(yyvsp[-1]);
  3100. yyvsp[-1] = PctReverse(yyvsp[-1]);
  3101. yyval = PctCreateNode(DBOP_content_vector_or, DBVALUEKIND_CONTENTVECTOR, yyvsp[-1], NULL);
  3102. if (NULL == yyval)
  3103. {
  3104. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3105. YYABORT(E_OUTOFMEMORY);
  3106. }
  3107. yyval->value.pdbcntntvcValue->dwRankingMethod = m_pIPSession->GetRankingMethod();
  3108. yyval->value.pdbcntntvcValue->lWeight = DEFAULTWEIGHT;
  3109. }
  3110. break;
  3111. case 141:
  3112. {
  3113. AssertReq(yyvsp[-2]);
  3114. AssertReq(yyvsp[0]);
  3115. Assert((DBOP_content == yyvsp[0]->op) || (DBOP_or == yyvsp[0]->op) || (DBOP_content_proximity == yyvsp[0]->op));
  3116. yyval = PctLink(yyvsp[0], yyvsp[-2]);
  3117. if (NULL == yyval)
  3118. {
  3119. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3120. YYABORT(E_OUTOFMEMORY);
  3121. }
  3122. }
  3123. break;
  3124. case 142:
  3125. {
  3126. AssertReq(yyvsp[0]);
  3127. Assert((DBOP_content == yyvsp[0]->op) || (DBOP_or == yyvsp[0]->op) || (DBOP_content_proximity == yyvsp[0]->op));
  3128. yyval = yyvsp[0];
  3129. }
  3130. break;
  3131. case 143:
  3132. {
  3133. AssertReq(yyvsp[-4]);
  3134. AssertReq(yyvsp[-1]);
  3135. if ((yyvsp[-1]->value.pvarValue->dblVal < 0.0) ||
  3136. (yyvsp[-1]->value.pvarValue->dblVal > 1.0))
  3137. {
  3138. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_WEIGHT_OUT_OF_RANGE);
  3139. WCHAR wchErr[30];
  3140. swprintf(wchErr, L"%f", yyvsp[-1]->value.pvarValue->dblVal);
  3141. m_pIPTProperties->SetErrorToken(wchErr);
  3142. YYABORT(DB_E_ERRORSINCOMMAND);
  3143. }
  3144. yyval = yyvsp[-4];
  3145. SetLWeight(yyval, (LONG) (yyvsp[-1]->value.pvarValue->dblVal * DEFAULTWEIGHT));
  3146. WCHAR wchWeight[10];
  3147. if (swprintf(wchWeight, L"%d", (LONG) (yyvsp[-1]->value.pvarValue->dblVal * DEFAULTWEIGHT)))
  3148. {
  3149. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"["));
  3150. m_pIPTProperties->AppendCiRestriction(wchWeight, wcslen(wchWeight));
  3151. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"] "));
  3152. }
  3153. DeleteDBQT(yyvsp[-1]);
  3154. yyvsp[-1] = NULL;
  3155. }
  3156. break;
  3157. case 144:
  3158. {
  3159. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" "));
  3160. yyval = yyvsp[0];
  3161. }
  3162. break;
  3163. case 149:
  3164. {
  3165. HRESULT hr = CoerceScalar(VT_R8, &yyvsp[0]);
  3166. if (S_OK != hr)
  3167. YYABORT(hr);
  3168. yyval = yyvsp[0];
  3169. }
  3170. break;
  3171. case 150:
  3172. {
  3173. yyval = NULL;
  3174. }
  3175. break;
  3176. case 151:
  3177. {
  3178. HRESULT hr = CoerceScalar(VT_I4, &yyvsp[0]);
  3179. if (S_OK != hr)
  3180. YYABORT(hr);
  3181. if (0 != yyvsp[0]->value.pvarValue->lVal)
  3182. {
  3183. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  3184. WCHAR wchErr[30];
  3185. swprintf(wchErr, L"%d", yyvsp[0]->value.pvarValue->lVal);
  3186. m_pIPTProperties->SetErrorToken(wchErr);
  3187. m_pIPTProperties->SetErrorToken(L"0");
  3188. YYABORT(DB_E_ERRORSINCOMMAND);
  3189. }
  3190. DeleteDBQT(yyvsp[0]);
  3191. yyvsp[0] = NULL;
  3192. yyval = NULL;
  3193. }
  3194. break;
  3195. case 152:
  3196. {
  3197. AssertReq(!yyvsp[-3]);
  3198. AssertReq(yyvsp[-2]);
  3199. HRESULT hr = HrQeTreeCopy(&yyval, m_pIPTProperties->GetContainsColumn());
  3200. if (FAILED(hr))
  3201. {
  3202. m_pIPTProperties->SetErrorHResult(hr, MONSQL_OUT_OF_MEMORY);
  3203. YYABORT(hr);
  3204. }
  3205. m_pIPTProperties->UseCiColumn(L'$');
  3206. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3207. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[-2]->value.pvValue)->bstrVal,
  3208. wcslen(((PROPVARIANT*)yyvsp[-2]->value.pvValue)->bstrVal));
  3209. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3210. yyval = PctCreateNode(DBOP_content_freetext, DBVALUEKIND_CONTENT, yyval, NULL);
  3211. if (NULL == yyval)
  3212. {
  3213. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3214. YYABORT(E_OUTOFMEMORY);
  3215. }
  3216. yyval->value.pdbcntntValue->pwszPhrase = CoTaskStrDup(((PROPVARIANT*)yyvsp[-2]->value.pvValue)->bstrVal);
  3217. yyval->value.pdbcntntValue->dwGenerateMethod = GENERATE_METHOD_EXACT;
  3218. yyval->value.pdbcntntValue->lWeight = DEFAULTWEIGHT;
  3219. yyval->value.pdbcntntValue->lcid = m_pIPSession->GetLCID();
  3220. DeleteDBQT(m_pIPTProperties->GetContainsColumn());
  3221. m_pIPTProperties->SetContainsColumn(NULL);
  3222. DeleteDBQT(yyvsp[-2]);
  3223. yyvsp[-2] = NULL;
  3224. }
  3225. break;
  3226. case 153:
  3227. {
  3228. AssertReq(yyvsp[-2]);
  3229. AssertReq(yyvsp[0]);
  3230. m_pIPTProperties->UseCiColumn(L'#');
  3231. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3232. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal,
  3233. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal));
  3234. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3235. yyval = PctCreateNode(DBOP_like, DBVALUEKIND_LIKE, yyvsp[-2], yyvsp[0], NULL);
  3236. if (NULL == yyval)
  3237. {
  3238. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3239. YYABORT(E_OUTOFMEMORY);
  3240. }
  3241. yyval->value.pdblikeValue->guidDialect = DBGUID_LIKE_OFS;
  3242. yyval->value.pdblikeValue->lWeight = DEFAULTWEIGHT;
  3243. }
  3244. break;
  3245. case 154:
  3246. {
  3247. AssertReq(yyvsp[-2]);
  3248. AssertReq(yyvsp[0]);
  3249. m_pIPTProperties->UseCiColumn(L'#');
  3250. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3251. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal,
  3252. wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal));
  3253. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3254. yyvsp[-1] = PctCreateNode(DBOP_like, DBVALUEKIND_LIKE, yyvsp[-2], yyvsp[0], NULL);
  3255. if (NULL == yyval)
  3256. {
  3257. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3258. YYABORT(E_OUTOFMEMORY);
  3259. }
  3260. yyvsp[-1]->value.pdblikeValue->guidDialect = DBGUID_LIKE_OFS;
  3261. yyvsp[-1]->value.pdblikeValue->lWeight = DEFAULTWEIGHT;
  3262. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[-1]);
  3263. }
  3264. break;
  3265. case 155:
  3266. {
  3267. UINT cLen = wcslen(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal);
  3268. BSTR bstrCopy = SysAllocStringLen(NULL, 4 * cLen);
  3269. if ( 0 == bstrCopy )
  3270. {
  3271. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3272. YYABORT( E_OUTOFMEMORY );
  3273. }
  3274. UINT j = 0;
  3275. for (UINT i = 0; i <= cLen; i++)
  3276. {
  3277. switch ( ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i] )
  3278. {
  3279. case L'%':
  3280. bstrCopy[j++] = L'*';
  3281. break;
  3282. case L'_':
  3283. bstrCopy[j++] = L'?';
  3284. break;
  3285. case L'|':
  3286. bstrCopy[j++] = L'|';
  3287. bstrCopy[j++] = L'|';
  3288. break;
  3289. case L'*':
  3290. bstrCopy[j++] = L'|';
  3291. bstrCopy[j++] = L'[';
  3292. bstrCopy[j++] = L'*';
  3293. bstrCopy[j++] = L']';
  3294. break;
  3295. case L'?':
  3296. bstrCopy[j++] = L'|';
  3297. bstrCopy[j++] = L'[';
  3298. bstrCopy[j++] = L'?';
  3299. bstrCopy[j++] = L']';
  3300. break;
  3301. case L'[':
  3302. /* UNDONE: Make sure we're not going out of range with these tests*/
  3303. if ((L'%' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+1]) &&
  3304. (L']' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+2]))
  3305. {
  3306. bstrCopy[j++] = L'%';
  3307. i = i + 2;
  3308. }
  3309. else if ((L'_' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+1]) &&
  3310. (L']' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+2]))
  3311. {
  3312. bstrCopy[j++] = L'_';
  3313. i = i + 2;
  3314. }
  3315. else if ((L'[' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+1]) &&
  3316. (L']' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+2]))
  3317. {
  3318. bstrCopy[j++] = L'[';
  3319. i = i + 2;
  3320. }
  3321. else if ((L'^' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+1]) &&
  3322. (L']' == ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+2]) &&
  3323. (wcschr((WCHAR*)&(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i+3]), L']')))
  3324. {
  3325. bstrCopy[j++] = L'|';
  3326. bstrCopy[j++] = L'[';
  3327. bstrCopy[j++] = L'^';
  3328. bstrCopy[j++] = L']';
  3329. i = i + 2;
  3330. }
  3331. else
  3332. {
  3333. bstrCopy[j++] = L'|';
  3334. bstrCopy[j++] = ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i++];
  3335. while ((((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i] != L']') && (i < cLen))
  3336. bstrCopy[j++] = ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i++];
  3337. if (i < cLen)
  3338. bstrCopy[j++] = ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i];
  3339. }
  3340. break;
  3341. default:
  3342. bstrCopy[j++] = ((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal[i];
  3343. break;
  3344. }
  3345. }
  3346. SysFreeString(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal);
  3347. ((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal = CoTaskStrDup(bstrCopy);
  3348. ((PROPVARIANT*)yyvsp[0]->value.pvValue)->vt = VT_LPWSTR;
  3349. SysFreeString(bstrCopy);
  3350. yyval = yyvsp[0];
  3351. }
  3352. break;
  3353. case 156:
  3354. {
  3355. AssertReq(yyvsp[-4]);
  3356. AssertReq(yyvsp[-2]);
  3357. m_pIPTProperties->UseCiColumn(L'#');
  3358. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3359. m_pIPTProperties->AppendCiRestriction(((PROPVARIANT*)yyvsp[-2]->value.pvValue)->pwszVal,
  3360. wcslen(((PROPVARIANT*)yyvsp[-2]->value.pvValue)->pwszVal));
  3361. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"\""));
  3362. yyval = PctCreateNode(DBOP_like, DBVALUEKIND_LIKE, yyvsp[-4], yyvsp[-2], NULL);
  3363. if (NULL == yyval)
  3364. {
  3365. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3366. YYABORT(E_OUTOFMEMORY);
  3367. }
  3368. yyval->value.pdblikeValue->guidDialect = DBGUID_LIKE_OFS;
  3369. yyval->value.pdblikeValue->lWeight = DEFAULTWEIGHT;
  3370. }
  3371. break;
  3372. case 157:
  3373. {
  3374. AssertReq(yyvsp[0]);
  3375. HRESULT hr = CoerceScalar(VT_LPWSTR, &yyvsp[0]);
  3376. if (S_OK != hr)
  3377. YYABORT(hr);
  3378. LPWSTR pwszMatchString = ((PROPVARIANT*)yyvsp[0]->value.pvValue)->pwszVal;
  3379. while (*pwszMatchString)
  3380. {
  3381. /* perform some soundness checking on string since Index Server won't be happy*/
  3382. /* with an ill formed string*/
  3383. if (L'|' == *pwszMatchString++)
  3384. {
  3385. hr = DB_E_ERRORSINCOMMAND;
  3386. switch ( *pwszMatchString++ )
  3387. {
  3388. case L'(':
  3389. while (*pwszMatchString)
  3390. if (L'|' == *pwszMatchString++)
  3391. if (*pwszMatchString)
  3392. if (L')' == *pwszMatchString++)
  3393. {
  3394. hr = S_OK;
  3395. break;
  3396. }
  3397. break;
  3398. case L'{':
  3399. while (*pwszMatchString)
  3400. if (L'|' == *pwszMatchString++)
  3401. if (*pwszMatchString)
  3402. if (L'}' == *pwszMatchString++)
  3403. {
  3404. hr = S_OK;
  3405. break;
  3406. }
  3407. break;
  3408. default:
  3409. hr = S_OK;
  3410. }
  3411. }
  3412. }
  3413. if (S_OK != hr)
  3414. {
  3415. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_MATCH_STRING);
  3416. YYABORT(hr);
  3417. }
  3418. yyval = yyvsp[0];
  3419. }
  3420. break;
  3421. case 158:
  3422. {
  3423. AssertReq(yyvsp[-2]);
  3424. AssertReq(yyvsp[-1]);
  3425. DBCOMMANDTREE * pct = 0;
  3426. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3427. {
  3428. pct = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  3429. if (NULL == pct)
  3430. {
  3431. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3432. YYABORT( E_OUTOFMEMORY );
  3433. }
  3434. DBCOMMANDTREE* pctList=yyvsp[0];
  3435. UINT i = 0;
  3436. pct->value.pvarValue->vt = m_pIPTProperties->GetDBType();
  3437. ((PROPVARIANT*)pct->value.pvarValue)->caub.cElems = GetNumberOfSiblings(yyvsp[0]);
  3438. if (0 == ((PROPVARIANT*)pct->value.pvarValue)->caub.cElems)
  3439. {
  3440. ((PROPVARIANT*)pct->value.pvarValue)->caub.pElems = (UCHAR*) NULL;
  3441. }
  3442. else
  3443. {
  3444. switch ( m_pIPTProperties->GetDBType() )
  3445. {
  3446. case (VT_UI1|VT_VECTOR):
  3447. ((PROPVARIANT*)pct->value.pvarValue)->caub.pElems =
  3448. (UCHAR*) CoTaskMemAlloc(sizeof(UCHAR)*((PROPVARIANT*)pct->value.pvarValue)->caub.cElems);
  3449. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->caub.pElems)
  3450. {
  3451. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3452. YYABORT( E_OUTOFMEMORY );
  3453. }
  3454. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->caub.cElems; i++)
  3455. {
  3456. ((PROPVARIANT*)pct->value.pvarValue)->caub.pElems[i] = pctList->value.pvarValue->bVal;
  3457. pctList = pctList->pctNextSibling;
  3458. }
  3459. break;
  3460. case (VT_I1|VT_VECTOR):
  3461. ((PROPVARIANT*)pct->value.pvarValue)->cac.pElems =
  3462. (CHAR*) CoTaskMemAlloc(sizeof(CHAR)*((PROPVARIANT*)pct->value.pvarValue)->cac.cElems);
  3463. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cac.pElems)
  3464. {
  3465. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3466. YYABORT( E_OUTOFMEMORY );
  3467. }
  3468. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cac.cElems; i++)
  3469. {
  3470. ((PROPVARIANT*)pct->value.pvarValue)->cac.pElems[i] = pctList->value.pvarValue->cVal;
  3471. pctList = pctList->pctNextSibling;
  3472. }
  3473. break;
  3474. case (VT_UI2|VT_VECTOR):
  3475. ((PROPVARIANT*)pct->value.pvarValue)->caui.pElems =
  3476. (USHORT*) CoTaskMemAlloc(sizeof(USHORT)*((PROPVARIANT*)pct->value.pvarValue)->caui.cElems);
  3477. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->caui.pElems)
  3478. {
  3479. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3480. YYABORT( E_OUTOFMEMORY );
  3481. }
  3482. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->caui.cElems; i++)
  3483. {
  3484. ((PROPVARIANT*)pct->value.pvarValue)->caui.pElems[i] = pctList->value.pvarValue->uiVal;
  3485. pctList = pctList->pctNextSibling;
  3486. }
  3487. break;
  3488. case (VT_I2|VT_VECTOR):
  3489. ((PROPVARIANT*)pct->value.pvarValue)->cai.pElems =
  3490. (SHORT*) CoTaskMemAlloc(sizeof(SHORT)*((PROPVARIANT*)pct->value.pvarValue)->cai.cElems);
  3491. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cai.pElems)
  3492. {
  3493. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3494. YYABORT( E_OUTOFMEMORY );
  3495. }
  3496. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cai.cElems; i++)
  3497. {
  3498. ((PROPVARIANT*)pct->value.pvarValue)->cai.pElems[i] = pctList->value.pvarValue->iVal;
  3499. pctList = pctList->pctNextSibling;
  3500. }
  3501. break;
  3502. case (VT_UI4|VT_VECTOR):
  3503. ((PROPVARIANT*)pct->value.pvarValue)->caul.pElems =
  3504. (ULONG*) CoTaskMemAlloc(sizeof(ULONG)*((PROPVARIANT*)pct->value.pvarValue)->caul.cElems);
  3505. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->caul.pElems)
  3506. {
  3507. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3508. YYABORT( E_OUTOFMEMORY );
  3509. }
  3510. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->caul.cElems; i++)
  3511. {
  3512. ((PROPVARIANT*)pct->value.pvarValue)->caul.pElems[i] = pctList->value.pvarValue->ulVal;
  3513. pctList = pctList->pctNextSibling;
  3514. }
  3515. break;
  3516. case (VT_I4|VT_VECTOR):
  3517. ((PROPVARIANT*)pct->value.pvarValue)->cal.pElems =
  3518. (LONG*) CoTaskMemAlloc(sizeof(LONG)*((PROPVARIANT*)pct->value.pvarValue)->cal.cElems);
  3519. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cal.pElems)
  3520. {
  3521. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3522. YYABORT( E_OUTOFMEMORY );
  3523. }
  3524. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cal.cElems; i++)
  3525. {
  3526. ((PROPVARIANT*)pct->value.pvarValue)->cal.pElems[i] = pctList->value.pvarValue->lVal;
  3527. pctList = pctList->pctNextSibling;
  3528. }
  3529. break;
  3530. case (VT_UI8|VT_VECTOR):
  3531. ((PROPVARIANT*)pct->value.pvarValue)->cauh.pElems =
  3532. (ULARGE_INTEGER*) CoTaskMemAlloc(sizeof(ULARGE_INTEGER)*((PROPVARIANT*)pct->value.pvarValue)->cauh.cElems);
  3533. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cauh.pElems)
  3534. {
  3535. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3536. YYABORT( E_OUTOFMEMORY );
  3537. }
  3538. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cauh.cElems; i++)
  3539. {
  3540. ((PROPVARIANT*)pct->value.pvarValue)->cauh.pElems[i] = ((PROPVARIANT*)pctList->value.pvarValue)->uhVal;
  3541. pctList = pctList->pctNextSibling;
  3542. }
  3543. break;
  3544. case (VT_I8|VT_VECTOR):
  3545. ((PROPVARIANT*)pct->value.pvarValue)->cah.pElems =
  3546. (LARGE_INTEGER*) CoTaskMemAlloc(sizeof(LARGE_INTEGER)*((PROPVARIANT*)pct->value.pvarValue)->cah.cElems);
  3547. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cah.pElems)
  3548. {
  3549. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3550. YYABORT( E_OUTOFMEMORY );
  3551. }
  3552. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cah.cElems; i++)
  3553. {
  3554. ((PROPVARIANT*)pct->value.pvarValue)->cah.pElems[i] = ((PROPVARIANT*)pctList->value.pvarValue)->hVal;
  3555. pctList = pctList->pctNextSibling;
  3556. }
  3557. break;
  3558. case (VT_R4|VT_VECTOR):
  3559. ((PROPVARIANT*)pct->value.pvarValue)->caflt.pElems =
  3560. (float*) CoTaskMemAlloc(sizeof(float)*((PROPVARIANT*)pct->value.pvarValue)->caflt.cElems);
  3561. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->caflt.pElems)
  3562. {
  3563. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3564. YYABORT( E_OUTOFMEMORY );
  3565. }
  3566. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->caflt.cElems; i++)
  3567. {
  3568. ((PROPVARIANT*)pct->value.pvarValue)->caflt.pElems[i] = pctList->value.pvarValue->fltVal;
  3569. pctList = pctList->pctNextSibling;
  3570. }
  3571. break;
  3572. case (VT_R8|VT_VECTOR):
  3573. ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems =
  3574. (double*) CoTaskMemAlloc(sizeof(double)*((PROPVARIANT*)pct->value.pvarValue)->cadbl.cElems);
  3575. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems)
  3576. {
  3577. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3578. YYABORT( E_OUTOFMEMORY );
  3579. }
  3580. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cadbl.cElems; i++)
  3581. {
  3582. ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems[i] = pctList->value.pvarValue->dblVal;
  3583. pctList = pctList->pctNextSibling;
  3584. }
  3585. break;
  3586. case (VT_BOOL|VT_VECTOR):
  3587. ((PROPVARIANT*)pct->value.pvarValue)->cabool.pElems =
  3588. (VARIANT_BOOL*) CoTaskMemAlloc(sizeof(VARIANT_BOOL)*((PROPVARIANT*)pct->value.pvarValue)->cabool.cElems);
  3589. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cabool.pElems)
  3590. {
  3591. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3592. YYABORT( E_OUTOFMEMORY );
  3593. }
  3594. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cabool.cElems; i++)
  3595. {
  3596. ((PROPVARIANT*)pct->value.pvarValue)->cabool.pElems[i] = pctList->value.pvarValue->boolVal;
  3597. pctList = pctList->pctNextSibling;
  3598. }
  3599. break;
  3600. case (VT_CY|VT_VECTOR):
  3601. ((PROPVARIANT*)pct->value.pvarValue)->cacy.pElems =
  3602. (CY*) CoTaskMemAlloc(sizeof(CY)*((PROPVARIANT*)pct->value.pvarValue)->cacy.cElems);
  3603. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cacy.pElems)
  3604. {
  3605. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3606. YYABORT( E_OUTOFMEMORY );
  3607. }
  3608. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cacy.cElems; i++)
  3609. {
  3610. ((PROPVARIANT*)pct->value.pvarValue)->cacy.pElems[i] =
  3611. ((PROPVARIANT*)pctList->value.pvarValue)->cyVal;
  3612. pctList = pctList->pctNextSibling;
  3613. }
  3614. break;
  3615. case (VT_DATE|VT_VECTOR):
  3616. ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems =
  3617. (double*) CoTaskMemAlloc(sizeof(double)*((PROPVARIANT*)pct->value.pvarValue)->cadbl.cElems);
  3618. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems)
  3619. {
  3620. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3621. YYABORT( E_OUTOFMEMORY );
  3622. }
  3623. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cadbl.cElems; i++)
  3624. {
  3625. ((PROPVARIANT*)pct->value.pvarValue)->cadbl.pElems[i] =
  3626. ((PROPVARIANT*)pctList->value.pvarValue)->date;
  3627. pctList = pctList->pctNextSibling;
  3628. }
  3629. break;
  3630. case (VT_FILETIME|VT_VECTOR):
  3631. ((PROPVARIANT*)pct->value.pvarValue)->cafiletime.pElems =
  3632. (FILETIME*) CoTaskMemAlloc(sizeof(FILETIME)*((PROPVARIANT*)pct->value.pvarValue)->cafiletime.cElems);
  3633. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cafiletime.pElems)
  3634. {
  3635. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3636. YYABORT( E_OUTOFMEMORY );
  3637. }
  3638. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cafiletime.cElems; i++)
  3639. {
  3640. ((PROPVARIANT*)pct->value.pvarValue)->cafiletime.pElems[i] =
  3641. ((PROPVARIANT*)pctList->value.pvarValue)->filetime;
  3642. pctList = pctList->pctNextSibling;
  3643. }
  3644. break;
  3645. case (VT_BSTR|VT_VECTOR):
  3646. ((PROPVARIANT*)pct->value.pvarValue)->cabstr.pElems =
  3647. (BSTR*) CoTaskMemAlloc(sizeof(BSTR)*((PROPVARIANT*)pct->value.pvarValue)->cabstr.cElems);
  3648. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->cabstr.pElems)
  3649. {
  3650. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3651. YYABORT( E_OUTOFMEMORY );
  3652. }
  3653. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cabstr.cElems; i++)
  3654. {
  3655. ((PROPVARIANT*)pct->value.pvarValue)->cabstr.pElems[i] =
  3656. SysAllocString(pctList->value.pvarValue->bstrVal);
  3657. if ( 0 == ((PROPVARIANT*)pct->value.pvarValue)->cabstr.pElems[i] )
  3658. {
  3659. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3660. YYABORT( E_OUTOFMEMORY );
  3661. }
  3662. pctList = pctList->pctNextSibling;
  3663. }
  3664. break;
  3665. case (DBTYPE_STR|VT_VECTOR):
  3666. pct->value.pvarValue->vt = VT_LPSTR | VT_VECTOR;
  3667. ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems =
  3668. (LPSTR*) CoTaskMemAlloc(sizeof(LPSTR)*((PROPVARIANT*)pct->value.pvarValue)->calpstr.cElems);
  3669. if (NULL == ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems)
  3670. {
  3671. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3672. YYABORT( E_OUTOFMEMORY );
  3673. }
  3674. for (i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->calpstr.cElems; i++)
  3675. {
  3676. ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems[i] =
  3677. (LPSTR)CoTaskMemAlloc((lstrlenA(((PROPVARIANT*)pctList->value.pvarValue)->pszVal)+2)*sizeof(CHAR));
  3678. if ( 0 == ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems[i] )
  3679. {
  3680. /* free allocations made so far*/
  3681. for ( int j = i-1; j >= 0; j++ )
  3682. CoTaskMemFree( ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems[i] );
  3683. CoTaskMemFree( ((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems );
  3684. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3685. YYABORT( E_OUTOFMEMORY );
  3686. }
  3687. strcpy(((PROPVARIANT*)pct->value.pvarValue)->calpstr.pElems[i],
  3688. ((PROPVARIANT*)pctList->value.pvarValue)->pszVal);
  3689. pctList = pctList->pctNextSibling;
  3690. }
  3691. break;
  3692. case (DBTYPE_WSTR|VT_VECTOR):
  3693. pct->value.pvarValue->vt = VT_LPWSTR | VT_VECTOR;
  3694. ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems =
  3695. (LPWSTR*) CoTaskMemAlloc(sizeof(LPWSTR)*((PROPVARIANT*)pct->value.pvarValue)->calpwstr.cElems);
  3696. if ( 0 == ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems )
  3697. {
  3698. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3699. YYABORT( E_OUTOFMEMORY );
  3700. }
  3701. for ( i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->calpwstr.cElems; i++ )
  3702. {
  3703. ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems[i] =
  3704. CoTaskStrDup(((PROPVARIANT*)pctList->value.pvarValue)->pwszVal);
  3705. if ( 0 == ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems[i] )
  3706. {
  3707. /* free allocations made so far*/
  3708. for ( int j = i-1; j >= 0; j++ )
  3709. CoTaskMemFree( ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems[i] );
  3710. CoTaskMemFree( ((PROPVARIANT*)pct->value.pvarValue)->calpwstr.pElems );
  3711. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3712. YYABORT( E_OUTOFMEMORY );
  3713. }
  3714. pctList = pctList->pctNextSibling;
  3715. }
  3716. break;
  3717. case (VT_CLSID|VT_VECTOR):
  3718. pct->value.pvarValue->vt = VT_CLSID | VT_VECTOR;
  3719. ((PROPVARIANT*)pct->value.pvarValue)->cauuid.pElems =
  3720. (GUID*) CoTaskMemAlloc(sizeof(GUID)*((PROPVARIANT*)pct->value.pvarValue)->cauuid.cElems);
  3721. if ( NULL == ((PROPVARIANT*)pct->value.pvarValue)->cauuid.pElems )
  3722. {
  3723. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3724. YYABORT( E_OUTOFMEMORY );
  3725. }
  3726. for ( i = 0; i<((PROPVARIANT*)pct->value.pvarValue)->cauuid.cElems; i++ )
  3727. {
  3728. ((PROPVARIANT*)pct->value.pvarValue)->cauuid.pElems[i] =
  3729. *((PROPVARIANT*)pctList->value.pvarValue)->puuid;
  3730. pctList = pctList->pctNextSibling;
  3731. }
  3732. break;
  3733. default:
  3734. assert(!"PctAllocNode: illegal wKind");
  3735. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  3736. m_pIPTProperties->SetErrorToken(L"ARRAY");
  3737. DeleteDBQT( pct );
  3738. YYABORT(DB_E_ERRORSINCOMMAND);
  3739. }
  3740. }
  3741. }
  3742. else
  3743. {
  3744. switch ( m_pIPTProperties->GetDBType() )
  3745. {
  3746. case VT_UI1:
  3747. case VT_UI2:
  3748. case VT_UI4:
  3749. case VT_UI8:
  3750. /* Allows:*/
  3751. /* DBOP_allbits*/
  3752. /* DBOP_anybits*/
  3753. /* when the LHS is a non vector.*/
  3754. /**/
  3755. /* There isn't a way to say the following through SQL currently:*/
  3756. /* DBOP_anybits_all*/
  3757. /* DBOP_anybits_any*/
  3758. /* DBOP_allbits_all*/
  3759. /* DBOP_allbits_any*/
  3760. pct = yyvsp[0];
  3761. yyvsp[0] = 0;
  3762. break;
  3763. default:
  3764. assert(!"PctAllocNode: illegal wKind");
  3765. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  3766. m_pIPTProperties->SetErrorToken(L"ARRAY");
  3767. YYABORT(DB_E_ERRORSINCOMMAND);
  3768. }
  3769. }
  3770. if (yyvsp[0])
  3771. {
  3772. DeleteDBQT(yyvsp[0]);
  3773. yyvsp[0] = NULL;
  3774. }
  3775. yyvsp[-2]->pctNextSibling = pct;
  3776. yyvsp[-1]->pctFirstChild = yyvsp[-2];
  3777. yyval = yyvsp[-1];
  3778. }
  3779. break;
  3780. case 162:
  3781. {
  3782. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3783. yyval = PctCreateRelationalNode( DBOP_equal, DEFAULTWEIGHT );
  3784. else
  3785. yyval = PctCreateRelationalNode( DBOP_equal, DEFAULTWEIGHT );
  3786. if ( NULL == yyval )
  3787. {
  3788. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3789. YYABORT( E_OUTOFMEMORY );
  3790. }
  3791. m_pIPTProperties->AppendCiRestriction( VAL_AND_CCH_MINUS_NULL(L" = ") );
  3792. }
  3793. break;
  3794. case 163:
  3795. {
  3796. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3797. yyval = PctCreateRelationalNode( DBOP_equal_all, DEFAULTWEIGHT );
  3798. else
  3799. yyval = PctCreateRelationalNode( DBOP_allbits, DEFAULTWEIGHT );
  3800. if ( NULL == yyval )
  3801. {
  3802. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3803. YYABORT( E_OUTOFMEMORY );
  3804. }
  3805. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3806. m_pIPTProperties->AppendCiRestriction( VAL_AND_CCH_MINUS_NULL(L" = ^a ") );
  3807. else
  3808. m_pIPTProperties->AppendCiRestriction( VAL_AND_CCH_MINUS_NULL(L" ^a ") );
  3809. }
  3810. break;
  3811. case 164:
  3812. {
  3813. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3814. yyval = PctCreateRelationalNode( DBOP_equal_any, DEFAULTWEIGHT );
  3815. else
  3816. yyval = PctCreateRelationalNode( DBOP_anybits, DEFAULTWEIGHT );
  3817. if ( NULL == yyval )
  3818. {
  3819. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3820. YYABORT( E_OUTOFMEMORY );
  3821. }
  3822. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3823. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" = ^s "));
  3824. else
  3825. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" ^s "));
  3826. }
  3827. break;
  3828. case 165:
  3829. {
  3830. if ( m_pIPTProperties->GetDBType() & DBTYPE_VECTOR )
  3831. yyval = PctCreateRelationalNode( DBOP_not_equal, DEFAULTWEIGHT );
  3832. if ( NULL == yyval )
  3833. {
  3834. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY );
  3835. YYABORT( E_OUTOFMEMORY );
  3836. }
  3837. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" != ") );
  3838. }
  3839. break;
  3840. case 166:
  3841. {
  3842. yyval = PctCreateRelationalNode(DBOP_not_equal_all, DEFAULTWEIGHT);
  3843. if (NULL == yyval)
  3844. {
  3845. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3846. YYABORT( E_OUTOFMEMORY );
  3847. }
  3848. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" != ^a "));
  3849. }
  3850. break;
  3851. case 167:
  3852. {
  3853. yyval = PctCreateRelationalNode(DBOP_not_equal_any, DEFAULTWEIGHT);
  3854. if (NULL == yyval)
  3855. {
  3856. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3857. YYABORT( E_OUTOFMEMORY );
  3858. }
  3859. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" != ^s "));
  3860. }
  3861. break;
  3862. case 168:
  3863. {
  3864. yyval = PctCreateRelationalNode(DBOP_less, DEFAULTWEIGHT);
  3865. if (NULL == yyval)
  3866. {
  3867. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3868. YYABORT( E_OUTOFMEMORY );
  3869. }
  3870. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" < "));
  3871. }
  3872. break;
  3873. case 169:
  3874. {
  3875. yyval = PctCreateRelationalNode(DBOP_less_all, DEFAULTWEIGHT);
  3876. if (NULL == yyval)
  3877. {
  3878. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3879. YYABORT( E_OUTOFMEMORY );
  3880. }
  3881. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" < ^a "));
  3882. }
  3883. break;
  3884. case 170:
  3885. {
  3886. yyval = PctCreateRelationalNode(DBOP_less_any, DEFAULTWEIGHT);
  3887. if (NULL == yyval)
  3888. {
  3889. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3890. YYABORT( E_OUTOFMEMORY );
  3891. }
  3892. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" < ^s "));
  3893. }
  3894. break;
  3895. case 171:
  3896. {
  3897. yyval = PctCreateRelationalNode(DBOP_greater, DEFAULTWEIGHT);
  3898. if (NULL == yyval)
  3899. {
  3900. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3901. YYABORT( E_OUTOFMEMORY );
  3902. }
  3903. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" > "));
  3904. }
  3905. break;
  3906. case 172:
  3907. {
  3908. yyval = PctCreateRelationalNode(DBOP_greater_all, DEFAULTWEIGHT);
  3909. if (NULL == yyval)
  3910. {
  3911. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3912. YYABORT( E_OUTOFMEMORY );
  3913. }
  3914. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" > ^a "));
  3915. }
  3916. break;
  3917. case 173:
  3918. {
  3919. yyval = PctCreateRelationalNode(DBOP_greater_any, DEFAULTWEIGHT);
  3920. if (NULL == yyval)
  3921. {
  3922. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3923. YYABORT( E_OUTOFMEMORY );
  3924. }
  3925. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" > ^s "));
  3926. }
  3927. break;
  3928. case 174:
  3929. {
  3930. yyval = PctCreateRelationalNode(DBOP_less_equal, DEFAULTWEIGHT);
  3931. if (NULL == yyval)
  3932. {
  3933. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3934. YYABORT( E_OUTOFMEMORY );
  3935. }
  3936. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" <= "));
  3937. }
  3938. break;
  3939. case 175:
  3940. {
  3941. yyval = PctCreateRelationalNode(DBOP_less_equal_all, DEFAULTWEIGHT);
  3942. if (NULL == yyval)
  3943. {
  3944. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3945. YYABORT( E_OUTOFMEMORY );
  3946. }
  3947. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" <= ^a "));
  3948. }
  3949. break;
  3950. case 176:
  3951. {
  3952. yyval = PctCreateRelationalNode(DBOP_less_equal_any, DEFAULTWEIGHT);
  3953. if (NULL == yyval)
  3954. {
  3955. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3956. YYABORT( E_OUTOFMEMORY );
  3957. }
  3958. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" <= ^s "));
  3959. }
  3960. break;
  3961. case 177:
  3962. {
  3963. yyval = PctCreateRelationalNode(DBOP_greater_equal, DEFAULTWEIGHT);
  3964. if (NULL == yyval)
  3965. {
  3966. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3967. YYABORT( E_OUTOFMEMORY );
  3968. }
  3969. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" >= "));
  3970. }
  3971. break;
  3972. case 178:
  3973. {
  3974. yyval = PctCreateRelationalNode(DBOP_greater_equal_all, DEFAULTWEIGHT);
  3975. if (NULL == yyval)
  3976. {
  3977. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3978. YYABORT( E_OUTOFMEMORY );
  3979. }
  3980. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" >= ^a "));
  3981. }
  3982. break;
  3983. case 179:
  3984. {
  3985. yyval = PctCreateRelationalNode(DBOP_greater_equal_any, DEFAULTWEIGHT);
  3986. if (NULL == yyval)
  3987. {
  3988. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  3989. YYABORT( E_OUTOFMEMORY );
  3990. }
  3991. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" >= ^s "));
  3992. }
  3993. break;
  3994. case 180:
  3995. {
  3996. yyval = PctReverse(yyvsp[-1]);
  3997. }
  3998. break;
  3999. case 181:
  4000. {
  4001. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"{"));
  4002. }
  4003. break;
  4004. case 182:
  4005. {
  4006. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"}"));
  4007. }
  4008. break;
  4009. case 183:
  4010. {
  4011. yyval = NULL;
  4012. }
  4013. break;
  4014. case 185:
  4015. {
  4016. AssertReq(yyvsp[-2]);
  4017. if (NULL == yyvsp[0])
  4018. YYABORT(DB_E_CANTCONVERTVALUE);
  4019. yyval = PctLink(yyvsp[0], yyvsp[-2]);
  4020. if (NULL == yyval)
  4021. {
  4022. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4023. YYABORT( E_OUTOFMEMORY );
  4024. }
  4025. }
  4026. break;
  4027. case 186:
  4028. {
  4029. if (NULL == yyvsp[0])
  4030. YYABORT(DB_E_CANTCONVERTVALUE);
  4031. yyval = yyvsp[0];
  4032. }
  4033. break;
  4034. case 187:
  4035. {
  4036. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L","));
  4037. }
  4038. break;
  4039. case 188:
  4040. {
  4041. AssertReq(yyvsp[-2]);
  4042. yyvsp[-1] = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  4043. if (NULL == yyvsp[-1])
  4044. {
  4045. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4046. YYABORT( E_OUTOFMEMORY );
  4047. }
  4048. ((PROPVARIANT*)yyvsp[-1]->value.pvValue)->vt = VT_EMPTY;
  4049. yyval = PctCreateRelationalNode(DBOP_equal, DEFAULTWEIGHT);
  4050. if (NULL == yyval)
  4051. {
  4052. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4053. YYABORT( E_OUTOFMEMORY );
  4054. }
  4055. yyval->pctFirstChild = yyvsp[-2];
  4056. yyvsp[-2]->pctNextSibling = yyvsp[-1];
  4057. }
  4058. break;
  4059. case 189:
  4060. {
  4061. AssertReq(yyvsp[-2]);
  4062. yyvsp[-1] = PctAllocNode(DBVALUEKIND_VARIANT, DBOP_scalar_constant);
  4063. if (NULL == yyvsp[-1])
  4064. {
  4065. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4066. YYABORT( E_OUTOFMEMORY );
  4067. }
  4068. ((PROPVARIANT*)yyvsp[-1]->value.pvValue)->vt = VT_EMPTY;
  4069. /* $$ = PctCreateRelationalNode(DBOP_not_equal, DEFAULTWEIGHT);*/
  4070. yyval = PctCreateRelationalNode(DBOP_equal, DEFAULTWEIGHT);
  4071. if (NULL == yyval)
  4072. {
  4073. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4074. YYABORT( E_OUTOFMEMORY );
  4075. }
  4076. yyval->pctFirstChild = yyvsp[-2];
  4077. yyvsp[-2]->pctNextSibling = yyvsp[-1];
  4078. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyval);
  4079. if (NULL == yyval)
  4080. {
  4081. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4082. YYABORT( E_OUTOFMEMORY );
  4083. }
  4084. }
  4085. break;
  4086. case 191:
  4087. {
  4088. AssertReq(yyvsp[-2]);
  4089. AssertReq(yyvsp[0]);
  4090. yyval = PctCreateBooleanNode(DBOP_or, DEFAULTWEIGHT, yyvsp[-2], yyvsp[0]);
  4091. if (NULL == yyval)
  4092. {
  4093. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4094. YYABORT( E_OUTOFMEMORY );
  4095. }
  4096. }
  4097. break;
  4098. case 193:
  4099. {
  4100. AssertReq(yyvsp[-2]);
  4101. AssertReq(yyvsp[0]);
  4102. yyval = PctCreateBooleanNode(DBOP_and, DEFAULTWEIGHT, yyvsp[-2], yyvsp[0]);
  4103. if (NULL == yyval)
  4104. {
  4105. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4106. YYABORT( E_OUTOFMEMORY );
  4107. }
  4108. }
  4109. break;
  4110. case 195:
  4111. {
  4112. AssertReq(yyvsp[0]);
  4113. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[0]);
  4114. if (NULL == yyval)
  4115. {
  4116. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4117. YYABORT( E_OUTOFMEMORY );
  4118. }
  4119. }
  4120. break;
  4121. case 196:
  4122. {
  4123. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" OR "));
  4124. }
  4125. break;
  4126. case 197:
  4127. {
  4128. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" AND "));
  4129. }
  4130. break;
  4131. case 198:
  4132. {
  4133. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L" NOT "));
  4134. }
  4135. break;
  4136. case 200:
  4137. {
  4138. AssertReq(yyvsp[-2]);
  4139. yyval = PctCreateNode(DBOP_is_TRUE, yyvsp[-2], NULL);
  4140. if (NULL == yyval)
  4141. {
  4142. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4143. YYABORT( E_OUTOFMEMORY );
  4144. }
  4145. }
  4146. break;
  4147. case 201:
  4148. {
  4149. AssertReq(yyvsp[-2]);
  4150. yyval = PctCreateNode(DBOP_is_FALSE, yyvsp[-2], NULL);
  4151. if (NULL == yyval)
  4152. {
  4153. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4154. YYABORT( E_OUTOFMEMORY );
  4155. }
  4156. }
  4157. break;
  4158. case 202:
  4159. {
  4160. AssertReq(yyvsp[-2]);
  4161. yyval = PctCreateNode(DBOP_is_INVALID, yyvsp[-2], NULL);
  4162. if (NULL == yyval)
  4163. {
  4164. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4165. YYABORT( E_OUTOFMEMORY );
  4166. }
  4167. }
  4168. break;
  4169. case 203:
  4170. {
  4171. AssertReq(yyvsp[-2]);
  4172. yyvsp[-1] = PctCreateNode(DBOP_is_TRUE, yyvsp[-2], NULL);
  4173. if (NULL == yyvsp[-1])
  4174. {
  4175. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4176. YYABORT( E_OUTOFMEMORY );
  4177. }
  4178. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[-1]);
  4179. if (NULL == yyval)
  4180. {
  4181. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4182. YYABORT( E_OUTOFMEMORY );
  4183. }
  4184. }
  4185. break;
  4186. case 204:
  4187. {
  4188. AssertReq(yyvsp[-2]);
  4189. yyvsp[-1] = PctCreateNode(DBOP_is_FALSE, yyvsp[-2], NULL);
  4190. if (NULL == yyvsp[-1])
  4191. {
  4192. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4193. YYABORT( E_OUTOFMEMORY );
  4194. }
  4195. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[-1]);
  4196. if (NULL == yyval)
  4197. {
  4198. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4199. YYABORT( E_OUTOFMEMORY );
  4200. }
  4201. }
  4202. break;
  4203. case 205:
  4204. {
  4205. AssertReq(yyvsp[-2]);
  4206. yyvsp[-1] = PctCreateNode(DBOP_is_INVALID, yyvsp[-2], NULL);
  4207. if (NULL == yyvsp[-1])
  4208. {
  4209. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4210. YYABORT( E_OUTOFMEMORY );
  4211. }
  4212. yyval = PctCreateNotNode(DEFAULTWEIGHT, yyvsp[-1]);
  4213. if (NULL == yyval)
  4214. {
  4215. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4216. YYABORT( E_OUTOFMEMORY );
  4217. }
  4218. }
  4219. break;
  4220. case 206:
  4221. {
  4222. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L"("));
  4223. yyval = NULL;
  4224. }
  4225. break;
  4226. case 207:
  4227. {
  4228. AssertReq(yyvsp[0]);
  4229. m_pIPTProperties->AppendCiRestriction(VAL_AND_CCH_MINUS_NULL(L")"));
  4230. yyval = yyvsp[0];
  4231. }
  4232. break;
  4233. case 208:
  4234. {
  4235. AssertReq(yyvsp[-1]);
  4236. yyval = yyvsp[-1];
  4237. }
  4238. break;
  4239. case 209:
  4240. {
  4241. AssertReq(yyvsp[0]);
  4242. yyvsp[0] = PctReverse(yyvsp[0]);
  4243. yyval = PctCreateNode(DBOP_sort_list_anchor, yyvsp[0], NULL);
  4244. if (NULL == yyval)
  4245. {
  4246. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4247. YYABORT( E_OUTOFMEMORY );
  4248. }
  4249. }
  4250. break;
  4251. case 210:
  4252. {
  4253. AssertReq(yyvsp[-2]);
  4254. AssertReq(yyvsp[0]);
  4255. yyval = PctLink(yyvsp[0], yyvsp[-2]);
  4256. if (NULL == yyval)
  4257. {
  4258. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4259. YYABORT( E_OUTOFMEMORY );
  4260. }
  4261. }
  4262. break;
  4263. case 212:
  4264. {
  4265. AssertReq(yyvsp[-1]);
  4266. AssertReq(yyvsp[0]);
  4267. yyvsp[0]->value.pdbsrtinfValue->lcid = m_pIPSession->GetLCID();
  4268. yyvsp[0]->pctFirstChild = yyvsp[-1];
  4269. yyval = yyvsp[0];
  4270. }
  4271. break;
  4272. case 213:
  4273. {
  4274. yyval = PctCreateNode(DBOP_sort_list_element, DBVALUEKIND_SORTINFO, NULL);
  4275. if (NULL == yyval)
  4276. {
  4277. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4278. YYABORT( E_OUTOFMEMORY );
  4279. }
  4280. yyval->value.pdbsrtinfValue->fDesc = m_pIPTProperties->GetSortDesc();
  4281. }
  4282. break;
  4283. case 214:
  4284. {
  4285. yyval = PctCreateNode(DBOP_sort_list_element, DBVALUEKIND_SORTINFO, NULL);
  4286. if (NULL == yyval)
  4287. {
  4288. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4289. YYABORT( E_OUTOFMEMORY );
  4290. }
  4291. yyval->value.pdbsrtinfValue->fDesc = QUERY_SORTASCEND;
  4292. m_pIPTProperties->SetSortDesc(QUERY_SORTASCEND);
  4293. }
  4294. break;
  4295. case 215:
  4296. {
  4297. yyval = PctCreateNode(DBOP_sort_list_element, DBVALUEKIND_SORTINFO, NULL);
  4298. if (NULL == yyval)
  4299. {
  4300. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4301. YYABORT(E_OUTOFMEMORY );
  4302. }
  4303. yyval->value.pdbsrtinfValue->fDesc = QUERY_SORTDESCEND;
  4304. m_pIPTProperties->SetSortDesc(QUERY_SORTDESCEND);
  4305. }
  4306. break;
  4307. case 216:
  4308. {
  4309. /*@SetCiColumn does the clear m_pCMonarchSessionData->ClearCiColumn();*/
  4310. }
  4311. break;
  4312. case 218:
  4313. {
  4314. yyval = NULL;
  4315. }
  4316. break;
  4317. case 219:
  4318. {
  4319. yyval = yyvsp[0];
  4320. }
  4321. break;
  4322. case 223:
  4323. {
  4324. HRESULT hr = S_OK;
  4325. yyvsp[-7] = PctBuiltInProperty(yyvsp[-1]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  4326. if (NULL != yyvsp[-7])
  4327. {
  4328. /* This is a built-in friendly name. Definition better match built in definition.*/
  4329. if (*yyvsp[-5]->value.pGuid != yyvsp[-7]->value.pdbidValue->uGuid.guid ||
  4330. m_pIPTProperties->GetDBType() != yyvsp[0]->value.usValue ||
  4331. DBKIND_GUID_PROPID != yyvsp[-7]->value.pdbidValue->eKind ||
  4332. yyvsp[-3]->value.pvarValue->lVal != (long)yyvsp[-7]->value.pdbidValue->uName.ulPropid)
  4333. {
  4334. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_BUILTIN_PROPERTY);
  4335. m_pIPTProperties->SetErrorToken(yyvsp[-1]->value.pwszValue);
  4336. YYABORT(DB_E_ERRORSINCOMMAND);
  4337. }
  4338. }
  4339. else
  4340. m_pIPSession->m_pCPropertyList->SetPropertyEntry(yyvsp[-1]->value.pwszValue,
  4341. yyvsp[0]->value.ulValue,
  4342. *yyvsp[-5]->value.pGuid,
  4343. DBKIND_GUID_PROPID,
  4344. (LPWSTR) LongToPtr( yyvsp[-3]->value.pvarValue->lVal ),
  4345. m_pIPSession->GetGlobalDefinition());
  4346. if (FAILED(hr))
  4347. {
  4348. /* Unable to store the property name and/or values in the symbol table*/
  4349. m_pIPTProperties->SetErrorHResult(hr, MONSQL_PARSE_ERROR);
  4350. m_pIPTProperties->SetErrorToken(yyvsp[-1]->value.pwszValue);
  4351. YYABORT(DB_E_ERRORSINCOMMAND);
  4352. }
  4353. if (yyvsp[-7])
  4354. DeleteDBQT(yyvsp[-7]);
  4355. DeleteDBQT(yyvsp[-5]);
  4356. DeleteDBQT(yyvsp[-3]);
  4357. DeleteDBQT(yyvsp[-1]);
  4358. DeleteDBQT(yyvsp[0]);
  4359. yyval = NULL;
  4360. }
  4361. break;
  4362. case 224:
  4363. {
  4364. HRESULT hr = S_OK;
  4365. yyvsp[-7] = PctBuiltInProperty(yyvsp[-1]->value.pwszValue, m_pIPSession, m_pIPTProperties);
  4366. if (NULL != yyvsp[-7])
  4367. {
  4368. /* This is a built-in friendly name. Definition better match built in definition.*/
  4369. if (*yyvsp[-5]->value.pGuid != yyvsp[-7]->value.pdbidValue->uGuid.guid ||
  4370. m_pIPTProperties->GetDBType() != yyvsp[0]->value.ulValue ||
  4371. DBKIND_GUID_NAME != yyvsp[-7]->value.pdbidValue->eKind ||
  4372. 0 != _wcsicmp(((PROPVARIANT*)yyvsp[-3]->value.pvValue)->bstrVal, yyvsp[-7]->value.pdbidValue->uName.pwszName))
  4373. {
  4374. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_BUILTIN_PROPERTY);
  4375. /* m_pIPTProperties->SetErrorToken($1->value.pwszValue);*/
  4376. YYABORT(DB_E_ERRORSINCOMMAND);
  4377. }
  4378. }
  4379. else
  4380. hr = m_pIPSession->m_pCPropertyList->SetPropertyEntry(yyvsp[-1]->value.pwszValue,
  4381. yyvsp[0]->value.ulValue,
  4382. *yyvsp[-5]->value.pGuid,
  4383. DBKIND_GUID_NAME,
  4384. ((PROPVARIANT*)yyvsp[-3]->value.pvValue)->bstrVal,
  4385. m_pIPSession->GetGlobalDefinition());
  4386. if (FAILED(hr))
  4387. {
  4388. /* Unable to store the property name and/or values in the symbol table*/
  4389. m_pIPTProperties->SetErrorHResult(hr, MONSQL_PARSE_ERROR);
  4390. m_pIPTProperties->SetErrorToken(yyvsp[-1]->value.pwszValue);
  4391. YYABORT(DB_E_ERRORSINCOMMAND);
  4392. }
  4393. if (yyvsp[-7])
  4394. DeleteDBQT(yyvsp[-7]);
  4395. DeleteDBQT(yyvsp[-5]);
  4396. DeleteDBQT(yyvsp[-3]);
  4397. DeleteDBQT(yyvsp[-1]);
  4398. DeleteDBQT(yyvsp[0]);
  4399. }
  4400. break;
  4401. case 226:
  4402. {
  4403. yyval = PctCreateNode(DBOP_scalar_constant, DBVALUEKIND_UI2, NULL);
  4404. yyval->value.usValue = DBTYPE_WSTR|DBTYPE_BYREF;
  4405. }
  4406. break;
  4407. case 227:
  4408. {
  4409. yyval = yyvsp[0];
  4410. }
  4411. break;
  4412. case 228:
  4413. {
  4414. AssertReq(yyvsp[0]);
  4415. DBTYPE dbType = GetDBTypeFromStr(yyvsp[0]->value.pwszValue);
  4416. if ((DBTYPE_EMPTY == dbType) ||
  4417. (DBTYPE_BYREF == dbType) ||
  4418. (DBTYPE_VECTOR == dbType))
  4419. {
  4420. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4421. m_pIPTProperties->SetErrorToken(yyvsp[0]->value.pwszValue);
  4422. m_pIPTProperties->SetErrorToken(L"<base Indexing Service dbtype1");
  4423. YYABORT(DB_E_ERRORSINCOMMAND);
  4424. }
  4425. DeleteDBQT(yyvsp[0]);
  4426. yyvsp[0] = NULL;
  4427. yyval = PctCreateNode(DBOP_scalar_constant, DBVALUEKIND_UI2, NULL);
  4428. if (DBTYPE_WSTR == dbType || DBTYPE_STR == dbType)
  4429. dbType = dbType | DBTYPE_BYREF;
  4430. yyval->value.usValue = dbType;
  4431. }
  4432. break;
  4433. case 229:
  4434. {
  4435. AssertReq(yyvsp[-2]);
  4436. AssertReq(yyvsp[0]);
  4437. DBTYPE dbType1 = GetDBTypeFromStr(yyvsp[-2]->value.pwszValue);
  4438. DBTYPE dbType2 = GetDBTypeFromStr(yyvsp[0]->value.pwszValue);
  4439. if ((DBTYPE_BYREF == dbType1 || DBTYPE_VECTOR == dbType1) &&
  4440. (DBTYPE_BYREF == dbType2 || DBTYPE_VECTOR == dbType2))
  4441. {
  4442. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4443. m_pIPTProperties->SetErrorToken(yyvsp[0]->value.pwszValue);
  4444. m_pIPTProperties->SetErrorToken(
  4445. L"DBTYPE_I2, DBTYPE_I4, DBTYPE_R4, DBTYPE_R8, DBTYPE_CY, DBTYPE_DATE, DBTYPE_BSTR, DBTYPE_BOOL, DBTYPE_STR, DBTYPE_WSTR");
  4446. YYABORT(DB_E_ERRORSINCOMMAND);
  4447. }
  4448. if (DBTYPE_BYREF != dbType1 && DBTYPE_VECTOR != dbType1 &&
  4449. DBTYPE_BYREF != dbType2 && DBTYPE_VECTOR != dbType2)
  4450. {
  4451. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4452. m_pIPTProperties->SetErrorToken(yyvsp[0]->value.pwszValue);
  4453. m_pIPTProperties->SetErrorToken(L"DBTYPE_BYREF, DBTYPE_VECTOR");
  4454. YYABORT(DB_E_ERRORSINCOMMAND);
  4455. }
  4456. DeleteDBQT(yyvsp[-2]);
  4457. yyvsp[-2] = NULL;
  4458. DeleteDBQT(yyvsp[0]);
  4459. yyvsp[0] = NULL;
  4460. yyval = PctCreateNode(DBOP_scalar_constant, DBVALUEKIND_UI2, NULL);
  4461. yyval->value.usValue = dbType1 | dbType2;
  4462. }
  4463. break;
  4464. case 233:
  4465. {
  4466. GUID* pGuid = (GUID*) CoTaskMemAlloc(sizeof GUID); /* this will become part of tree*/
  4467. if (NULL == pGuid)
  4468. {
  4469. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4470. YYABORT( E_OUTOFMEMORY );
  4471. }
  4472. BOOL bRet = ParseGuid(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal, *pGuid);
  4473. if ( bRet && GUID_NULL != *pGuid)
  4474. {
  4475. SCODE sc = PropVariantClear((PROPVARIANT*)yyvsp[0]->value.pvValue);
  4476. Assert(SUCCEEDED(sc)); /* UNDONE: meaningful error message*/
  4477. CoTaskMemFree(yyvsp[0]->value.pvValue);
  4478. yyvsp[0]->wKind = DBVALUEKIND_GUID;
  4479. yyvsp[0]->value.pGuid = pGuid;
  4480. yyval = yyvsp[0];
  4481. }
  4482. else
  4483. {
  4484. CoTaskMemFree(pGuid);
  4485. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4486. m_pIPTProperties->SetErrorToken(((PROPVARIANT*)yyvsp[0]->value.pvValue)->bstrVal);
  4487. YYABORT(DB_E_ERRORSINCOMMAND);
  4488. }
  4489. }
  4490. break;
  4491. case 234:
  4492. {
  4493. yyval = NULL;
  4494. }
  4495. break;
  4496. case 235:
  4497. {
  4498. AssertReq(yyvsp[-1]);
  4499. AssertReq(yyvsp[0]);
  4500. if ((0==_wcsicmp(yyvsp[-1]->value.pwszValue, L"Jaccard")) &&
  4501. (0==_wcsicmp(yyvsp[0]->value.pwszValue, L"coefficient")))
  4502. m_pIPSession->SetRankingMethod(VECTOR_RANK_JACCARD);
  4503. else if ((0==_wcsicmp(yyvsp[-1]->value.pwszValue, L"dice")) &&
  4504. (0==_wcsicmp(yyvsp[0]->value.pwszValue, L"coefficient")))
  4505. m_pIPSession->SetRankingMethod(VECTOR_RANK_DICE);
  4506. else if ((0==_wcsicmp(yyvsp[-1]->value.pwszValue, L"inner")) &&
  4507. (0==_wcsicmp(yyvsp[0]->value.pwszValue, L"product")))
  4508. m_pIPSession->SetRankingMethod(VECTOR_RANK_INNER);
  4509. else
  4510. {
  4511. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4512. m_pIPTProperties->SetErrorToken(yyvsp[-1]->value.pwszValue);
  4513. m_pIPTProperties->SetErrorToken(L"MINIMUM, MAXIMUM, JACCARD COEFFICIENT, DICE COEFFICIENT, INNER PRODUCT");
  4514. YYABORT(DB_E_ERRORSINCOMMAND);
  4515. }
  4516. DeleteDBQT(yyvsp[0]);
  4517. yyvsp[0] = NULL;
  4518. DeleteDBQT(yyvsp[-1]);
  4519. yyvsp[-1] = NULL;
  4520. yyval = NULL;
  4521. }
  4522. break;
  4523. case 236:
  4524. {
  4525. AssertReq(yyvsp[0]);
  4526. if (0==_wcsicmp(yyvsp[0]->value.pwszValue, L"minimum"))
  4527. m_pIPSession->SetRankingMethod(VECTOR_RANK_MIN);
  4528. else if (0==_wcsicmp(yyvsp[0]->value.pwszValue, L"maximum"))
  4529. m_pIPSession->SetRankingMethod(VECTOR_RANK_MAX);
  4530. else
  4531. {
  4532. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4533. m_pIPTProperties->SetErrorToken(yyvsp[0]->value.pwszValue);
  4534. m_pIPTProperties->SetErrorToken(L"MINIMUM, MAXIMUM, JACCARD COEFFICIENT, DICE COEFFICIENT, INNER PRODUCT");
  4535. YYABORT(DB_E_ERRORSINCOMMAND);
  4536. }
  4537. DeleteDBQT(yyvsp[0]);
  4538. yyvsp[0] = NULL;
  4539. yyval = NULL;
  4540. }
  4541. break;
  4542. case 237:
  4543. {
  4544. if (0 != _wcsicmp(yyvsp[-1]->value.pwszValue, L"GLOBAL"))
  4545. {
  4546. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4547. m_pIPTProperties->SetErrorToken(yyvsp[-1]->value.pwszValue);
  4548. m_pIPTProperties->SetErrorToken(L"GLOBAL");
  4549. YYABORT(DB_E_ERRORSINCOMMAND);
  4550. }
  4551. if (0 == _wcsicmp(yyvsp[0]->value.pwszValue, L"ON"))
  4552. m_pIPSession->SetGlobalDefinition(TRUE);
  4553. else if (0 == _wcsicmp(yyvsp[0]->value.pwszValue, L"OFF"))
  4554. m_pIPSession->SetGlobalDefinition(FALSE);
  4555. else
  4556. {
  4557. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4558. m_pIPTProperties->SetErrorToken(yyvsp[0]->value.pwszValue);
  4559. m_pIPTProperties->SetErrorToken(L"ON, OFF");
  4560. YYABORT(DB_E_ERRORSINCOMMAND);
  4561. }
  4562. DeleteDBQT(yyvsp[-1]);
  4563. DeleteDBQT(yyvsp[0]);
  4564. yyval = NULL;
  4565. }
  4566. break;
  4567. case 238:
  4568. { /* _CREATE _VIEW view_name _AS _SELECT select_list from_clause*/
  4569. AssertReq( yyvsp[-4] );
  4570. AssertReq( yyvsp[-1] );
  4571. AssertReq( yyvsp[0] );
  4572. /**/
  4573. /* Can create views only on the current catalog*/
  4574. /**/
  4575. if ( 0 != _wcsicmp((yyvsp[-4]->value.pdbcntnttblValue)->pwszMachine, m_pIPSession->GetDefaultMachine()) &&
  4576. 0 != _wcsicmp((yyvsp[-4]->value.pdbcntnttblValue)->pwszCatalog, m_pIPSession->GetDefaultCatalog()) )
  4577. {
  4578. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR);
  4579. m_pIPTProperties->SetErrorToken( (yyvsp[-4]->pctNextSibling)->value.pwszValue );
  4580. m_pIPTProperties->SetErrorToken( L"<unqualified temporary view name>" );
  4581. YYABORT( DB_E_ERRORSINCOMMAND );
  4582. }
  4583. if ( DBOP_outall_name == yyvsp[-1]->op )
  4584. {
  4585. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4586. m_pIPTProperties->SetErrorToken( L"*" );
  4587. m_pIPTProperties->SetErrorToken( L"<select list>" );
  4588. YYABORT( DB_E_ERRORSINCOMMAND );
  4589. }
  4590. Assert( DBOP_content_table == yyvsp[-4]->op );
  4591. AssertReq( yyvsp[-4]->pctNextSibling ); /* name of the view*/
  4592. SCODE sc = S_OK;
  4593. /* This is the LA_proj, which doesn't have a NextSibling.*/
  4594. /* Use the next sibling to store contenttable tree*/
  4595. /* specified in the from_clause*/
  4596. Assert( 0 == yyvsp[-1]->pctNextSibling );
  4597. if ( L'#' != yyvsp[-4]->pctNextSibling->value.pwszValue[0] )
  4598. {
  4599. if ( m_pIPSession->GetGlobalDefinition() )
  4600. sc = m_pIPSession->GetGlobalViewList()->SetViewDefinition(
  4601. m_pIPSession,
  4602. m_pIPTProperties,
  4603. yyvsp[-4]->pctNextSibling->value.pwszValue,
  4604. NULL, /* all catalogs*/
  4605. yyvsp[-1]);
  4606. else
  4607. {
  4608. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4609. m_pIPTProperties->SetErrorToken( yyvsp[-4]->pctNextSibling->value.pwszValue );
  4610. m_pIPTProperties->SetErrorToken( L"<temporary view name>" );
  4611. YYABORT( DB_E_ERRORSINCOMMAND );
  4612. }
  4613. }
  4614. else
  4615. {
  4616. if ( 1 >= wcslen(yyvsp[-4]->pctNextSibling->value.pwszValue) )
  4617. {
  4618. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4619. m_pIPTProperties->SetErrorToken( yyvsp[-4]->pctNextSibling->value.pwszValue );
  4620. m_pIPTProperties->SetErrorToken( L"<temporary view name>" );
  4621. YYABORT( DB_E_ERRORSINCOMMAND );
  4622. }
  4623. else if ( L'#' == yyvsp[-4]->pctNextSibling->value.pwszValue[1] )
  4624. {
  4625. /* store the scope information for the view*/
  4626. yyvsp[-1]->pctNextSibling = yyvsp[0];
  4627. yyvsp[0] = 0;
  4628. sc = m_pIPSession->GetLocalViewList()->SetViewDefinition(
  4629. m_pIPSession,
  4630. m_pIPTProperties,
  4631. yyvsp[-4]->pctNextSibling->value.pwszValue,
  4632. (yyvsp[-4]->value.pdbcntnttblValue)->pwszCatalog,
  4633. yyvsp[-1]);
  4634. }
  4635. else
  4636. {
  4637. yyvsp[-1]->pctNextSibling = yyvsp[0];
  4638. yyvsp[0] = 0;
  4639. sc = m_pIPSession->GetGlobalViewList()->SetViewDefinition(
  4640. m_pIPSession,
  4641. m_pIPTProperties,
  4642. yyvsp[-4]->pctNextSibling->value.pwszValue,
  4643. (yyvsp[-4]->value.pdbcntnttblValue)->pwszCatalog,
  4644. yyvsp[-1]);
  4645. }
  4646. }
  4647. if ( FAILED(sc) )
  4648. {
  4649. if ( E_INVALIDARG == sc )
  4650. {
  4651. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_VIEW_ALREADY_DEFINED );
  4652. m_pIPTProperties->SetErrorToken( yyvsp[-4]->pctNextSibling->value.pwszValue );
  4653. m_pIPTProperties->SetErrorToken( (yyvsp[-4]->value.pdbcntnttblValue)->pwszCatalog );
  4654. YYABORT( DB_E_ERRORSINCOMMAND );
  4655. }
  4656. else
  4657. {
  4658. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4659. m_pIPTProperties->SetErrorToken( yyvsp[-4]->pctNextSibling->value.pwszValue );
  4660. YYABORT( DB_E_ERRORSINCOMMAND );
  4661. }
  4662. }
  4663. DeleteDBQT( yyvsp[-4] );
  4664. DeleteDBQT( yyvsp[-1] );
  4665. if ( 0 != yyvsp[0] )
  4666. DeleteDBQT( yyvsp[0] );
  4667. yyval = 0;
  4668. }
  4669. break;
  4670. case 239:
  4671. {
  4672. AssertReq( yyvsp[0] );
  4673. AssertReq( yyvsp[0]->pctNextSibling ); /* name of the view*/
  4674. SCODE sc = S_OK;
  4675. if ( L'#' != yyvsp[0]->pctNextSibling->value.pwszValue[0] )
  4676. {
  4677. if ( m_pIPSession->GetGlobalDefinition() )
  4678. sc = m_pIPSession->GetGlobalViewList()->DropViewDefinition( yyvsp[0]->pctNextSibling->value.pwszValue, NULL );
  4679. else
  4680. {
  4681. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4682. m_pIPTProperties->SetErrorToken( yyvsp[0]->pctNextSibling->value.pwszValue );
  4683. m_pIPTProperties->SetErrorToken( L"<temporary view name>" );
  4684. YYABORT( DB_E_ERRORSINCOMMAND );
  4685. }
  4686. }
  4687. else
  4688. {
  4689. if ( 1 >= wcslen(yyvsp[0]->pctNextSibling->value.pwszValue) )
  4690. {
  4691. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_PARSE_ERROR );
  4692. m_pIPTProperties->SetErrorToken( yyvsp[0]->pctNextSibling->value.pwszValue );
  4693. m_pIPTProperties->SetErrorToken( L"<temporary view name>" );
  4694. YYABORT( DB_E_ERRORSINCOMMAND );
  4695. }
  4696. else if ( L'#' == yyvsp[0]->pctNextSibling->value.pwszValue[1] )
  4697. sc = m_pIPSession->GetLocalViewList()->DropViewDefinition( yyvsp[0]->pctNextSibling->value.pwszValue,
  4698. (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  4699. else
  4700. sc = m_pIPSession->GetGlobalViewList()->DropViewDefinition( yyvsp[0]->pctNextSibling->value.pwszValue,
  4701. (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  4702. }
  4703. if ( FAILED(sc) )
  4704. {
  4705. m_pIPTProperties->SetErrorHResult( DB_E_ERRORSINCOMMAND, MONSQL_VIEW_NOT_DEFINED );
  4706. m_pIPTProperties->SetErrorToken( yyvsp[0]->pctNextSibling->value.pwszValue );
  4707. m_pIPTProperties->SetErrorToken( (yyvsp[0]->value.pdbcntnttblValue)->pwszCatalog );
  4708. YYABORT( DB_E_ERRORSINCOMMAND );
  4709. }
  4710. DeleteDBQT( yyvsp[0] );
  4711. yyval = 0;
  4712. }
  4713. break;
  4714. }
  4715. yyssp -= yym;
  4716. yystate = *yyssp;
  4717. yyvsp -= yym;
  4718. yym = yylhs[yyn];
  4719. if (yystate == 0 && yym == 0)
  4720. {
  4721. #if YYDEBUG
  4722. if (yydebug)
  4723. printf("%sdebug: after reduction, shifting from state 0 to\
  4724. state %d\n", YYPREFIX, YYFINAL);
  4725. #endif
  4726. yystate = YYFINAL;
  4727. *++yyssp = YYFINAL;
  4728. *++yyvsp = yyval;
  4729. if (yychar < 0)
  4730. {
  4731. YYAPI_VALUENAME = NULL;
  4732. try
  4733. {
  4734. if ( (yychar = YYLEX(&YYAPI_VALUENAME)) < 0 )
  4735. yychar = 0;
  4736. }
  4737. catch (HRESULT hr)
  4738. {
  4739. switch(hr)
  4740. {
  4741. case E_OUTOFMEMORY:
  4742. m_pIPTProperties->SetErrorHResult(DB_E_ERRORSINCOMMAND, MONSQL_OUT_OF_MEMORY);
  4743. YYABORT(E_OUTOFMEMORY);
  4744. break;
  4745. default:
  4746. YYABORT(QPARSE_E_INVALID_QUERY);
  4747. break;
  4748. }
  4749. }
  4750. #if YYDEBUG
  4751. if (yydebug)
  4752. {
  4753. yys = 0;
  4754. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  4755. if (!yys) yys = "illegal-symbol";
  4756. printf("%sdebug: state %d, reading %d (%s)\n",
  4757. YYPREFIX, YYFINAL, yychar, yys);
  4758. }
  4759. #endif
  4760. }
  4761. if (yychar == 0) goto yyaccept;
  4762. goto yyloop;
  4763. }
  4764. if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
  4765. yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  4766. yystate = yytable[yyn];
  4767. else
  4768. yystate = yydgoto[yym];
  4769. #if YYDEBUG
  4770. if (yydebug)
  4771. printf("%sdebug: after reduction, shifting from state %d \
  4772. to state %d\n", YYPREFIX, *yyssp, yystate);
  4773. #endif
  4774. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  4775. {
  4776. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  4777. xyyss.SetSize((unsigned) ( yyssp-xyyss.Get())+2);
  4778. yyssp = xyyss.Get() + yysspLoc;
  4779. }
  4780. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  4781. {
  4782. int yyvspLoc = (int) ( yyvsp - xyyvs.Get() );
  4783. xyyvs.SetSize((unsigned) ( yyvsp-xyyvs.Get())+2);
  4784. yyvsp = xyyvs.Get() + yyvspLoc;
  4785. }
  4786. *++yyssp = (short) yystate;
  4787. *++yyvsp = yyval;
  4788. goto yyloop;
  4789. yyabort:
  4790. EmptyValueStack(yylval);
  4791. return YYFATAL;
  4792. yyaccept:
  4793. return YYSUCCESS;
  4794. }