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

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