Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

891 lines
36 KiB

  1. /***************************************************************************/
  2. /* INFO.C */
  3. /* Copyright (C) 1995-96 SYWARE Inc., All rights reserved */
  4. /***************************************************************************/
  5. // Commenting #define out - causing compiler error - not sure if needed, compiles
  6. // okay without it.
  7. //#define WINVER 0x0400
  8. #include "precomp.h"
  9. #include <objbase.h>
  10. #include <initguid.h>
  11. #include "wbemidl.h"
  12. #include <comdef.h>
  13. //smart pointer
  14. _COM_SMARTPTR_TYPEDEF(IWbemServices, IID_IWbemServices);
  15. _COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, IID_IEnumWbemClassObject);
  16. //_COM_SMARTPTR_TYPEDEF(IWbemContext, IID_IWbemContext );
  17. _COM_SMARTPTR_TYPEDEF(IWbemLocator, IID_IWbemLocator);
  18. #include "drdbdr.h"
  19. /***************************************************************************/
  20. RETCODE SQL_API SQLGetInfo(
  21. HDBC hdbc,
  22. UWORD fInfoType,
  23. PTR rgbInfoValue,
  24. SWORD cbInfoValueMax,
  25. SWORD FAR *pcbInfoValue)
  26. {
  27. LPDBC lpdbc;
  28. /* Get connection handle */
  29. lpdbc = (LPDBC) hdbc;
  30. lpdbc->errcode = ERR_SUCCESS;
  31. //To make guarentee Ole is initialized per thread
  32. COleInitializationManager myOleManager;
  33. MyImpersonator im (lpdbc, "SQLGetInfo");
  34. /* Return the info value */
  35. switch (fInfoType) {
  36. /* INFOs that return a string */
  37. // case SQL_ACCESSIBLE_PROCEDURES:
  38. case SQL_ACCESSIBLE_TABLES:
  39. case SQL_OUTER_JOINS:
  40. case SQL_DATA_SOURCE_READ_ONLY:
  41. case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
  42. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  43. pcbInfoValue, (LPUSTR) "Y");
  44. break;
  45. case SQL_ACCESSIBLE_PROCEDURES:
  46. case SQL_COLUMN_ALIAS:
  47. case SQL_EXPRESSIONS_IN_ORDERBY:
  48. case SQL_LIKE_ESCAPE_CLAUSE:
  49. case SQL_MULT_RESULT_SETS:
  50. case SQL_NEED_LONG_DATA_LEN:
  51. case SQL_ODBC_SQL_OPT_IEF:
  52. case SQL_ORDER_BY_COLUMNS_IN_SELECT:
  53. case SQL_PROCEDURES:
  54. case SQL_ROW_UPDATES:
  55. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  56. pcbInfoValue, (LPUSTR) "N");
  57. break;
  58. case SQL_DATA_SOURCE_NAME:
  59. if (s_lstrcmp( (char*)lpdbc->szDSN, " "))
  60. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  61. pcbInfoValue, lpdbc->szDSN);
  62. else
  63. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  64. pcbInfoValue, (LPUSTR) "");
  65. break;
  66. case SQL_DATABASE_NAME:
  67. if (lpdbc->lpISAM != NULL)
  68. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  69. pcbInfoValue, (LPUSTR) ISAMDatabase(lpdbc->lpISAM));
  70. else
  71. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  72. pcbInfoValue, (LPUSTR) "");
  73. break;
  74. case SQL_KEYWORDS:
  75. case SQL_OWNER_TERM:
  76. case SQL_PROCEDURE_TERM:
  77. // case SQL_SERVER_NAME:
  78. case SQL_SPECIAL_CHARACTERS:
  79. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  80. pcbInfoValue, (LPUSTR) "");
  81. break;
  82. case SQL_SERVER_NAME:
  83. {
  84. LPUSTR pName = ISAMServer(lpdbc->lpISAM);
  85. if (!pName)
  86. {
  87. lpdbc->errcode = ERR_ISAM;
  88. }
  89. else
  90. {
  91. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  92. pcbInfoValue, pName);
  93. delete (LPSTR)pName;
  94. }
  95. }
  96. break;
  97. case SQL_MULTIPLE_ACTIVE_TXN:
  98. if (lpdbc->lpISAM->fTxnCapable != SQL_TC_NONE) {
  99. if (lpdbc->lpISAM->fMultipleActiveTxn)
  100. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  101. pcbInfoValue, (LPUSTR) "Y");
  102. else
  103. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  104. pcbInfoValue, (LPUSTR) "N");
  105. }
  106. else
  107. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  108. pcbInfoValue, (LPUSTR) "N");
  109. break;
  110. case SQL_QUALIFIER_TERM:
  111. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  112. pcbInfoValue, (LPUSTR) "Namespace");
  113. break;
  114. case SQL_QUALIFIER_NAME_SEPARATOR:
  115. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  116. pcbInfoValue, (LPUSTR) ".");
  117. break;
  118. case SQL_SEARCH_PATTERN_ESCAPE:
  119. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  120. pcbInfoValue, (LPUSTR) "\\");
  121. break;
  122. case SQL_DBMS_NAME:
  123. {
  124. LPUSTR pName = ISAMName(lpdbc->lpISAM);
  125. if (!pName)
  126. {
  127. lpdbc->errcode = ERR_ISAM;
  128. }
  129. else
  130. {
  131. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  132. pcbInfoValue, pName);
  133. delete (LPSTR)pName;
  134. }
  135. }
  136. break;
  137. case SQL_DBMS_VER:
  138. {
  139. LPUSTR pVersion = ISAMVersion(lpdbc->lpISAM);
  140. if (!pVersion)
  141. {
  142. lpdbc->errcode = ERR_ISAM;
  143. }
  144. else
  145. {
  146. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  147. pcbInfoValue, pVersion);
  148. delete (LPSTR)pVersion;
  149. }
  150. }
  151. break;
  152. case SQL_DRIVER_NAME:
  153. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  154. pcbInfoValue, (LPUSTR) ISAMDriver(lpdbc->lpISAM));
  155. break;
  156. case SQL_DRIVER_ODBC_VER:
  157. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  158. pcbInfoValue, (LPUSTR) "02.10");
  159. break;
  160. case SQL_DRIVER_VER:
  161. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  162. pcbInfoValue, (LPUSTR) "01.00.0000");
  163. break;
  164. case SQL_IDENTIFIER_QUOTE_CHAR:
  165. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  166. pcbInfoValue, (LPUSTR) "\"");
  167. break;
  168. case SQL_TABLE_TERM:
  169. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  170. pcbInfoValue, (LPUSTR) "Class");
  171. break;
  172. case SQL_USER_NAME:
  173. lpdbc->errcode = ReturnString(rgbInfoValue, cbInfoValueMax,
  174. pcbInfoValue, (LPUSTR) "");
  175. break;
  176. /* INFOs that return a two byte value */
  177. case SQL_ACTIVE_CONNECTIONS:
  178. case SQL_ACTIVE_STATEMENTS:
  179. case SQL_MAX_COLUMNS_IN_INDEX:
  180. case SQL_MAX_COLUMNS_IN_SELECT:
  181. case SQL_MAX_COLUMNS_IN_TABLE:
  182. case SQL_MAX_OWNER_NAME_LEN:
  183. case SQL_MAX_PROCEDURE_NAME_LEN:
  184. case SQL_MAX_TABLES_IN_SELECT:
  185. *(SWORD FAR *)rgbInfoValue = 0;
  186. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  187. break;
  188. case SQL_MAX_QUALIFIER_NAME_LEN:
  189. *(SWORD FAR *)rgbInfoValue = 128;
  190. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  191. break;
  192. case SQL_CONCAT_NULL_BEHAVIOR:
  193. *(SWORD FAR *)rgbInfoValue = SQL_CB_NON_NULL;
  194. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  195. break;
  196. case SQL_CORRELATION_NAME:
  197. *(SWORD FAR *)rgbInfoValue = SQL_CN_ANY;
  198. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  199. break;
  200. case SQL_CURSOR_COMMIT_BEHAVIOR:
  201. case SQL_CURSOR_ROLLBACK_BEHAVIOR:
  202. if (lpdbc->lpISAM->fTxnCapable != SQL_TC_NONE) {
  203. if (lpdbc->lpISAM->fSchemaInfoTransactioned)
  204. *(SWORD FAR *)rgbInfoValue = SQL_CB_DELETE;
  205. else
  206. *(SWORD FAR *)rgbInfoValue = SQL_CB_CLOSE;
  207. }
  208. else
  209. *(SWORD FAR *)rgbInfoValue = SQL_CB_CLOSE;
  210. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  211. break;
  212. case SQL_FILE_USAGE:
  213. *(SWORD FAR *)rgbInfoValue = SQL_FILE_NOT_SUPPORTED;
  214. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  215. break;
  216. case SQL_GROUP_BY:
  217. *(SWORD FAR *)rgbInfoValue = SQL_GB_GROUP_BY_CONTAINS_SELECT;//SQL_GB_NOT_SUPPORTED;
  218. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  219. break;
  220. case SQL_IDENTIFIER_CASE:
  221. *(SWORD FAR *)rgbInfoValue = SQL_IC_MIXED;
  222. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  223. break;
  224. case SQL_QUOTED_IDENTIFIER_CASE:
  225. *(SWORD FAR *)rgbInfoValue = SQL_IC_SENSITIVE;
  226. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  227. break;
  228. case SQL_MAX_COLUMN_NAME_LEN:
  229. *(SWORD FAR *)rgbInfoValue = ISAMMaxColumnNameLength(lpdbc->lpISAM);
  230. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  231. break;
  232. case SQL_MAX_COLUMNS_IN_GROUP_BY:
  233. *(SWORD FAR *)rgbInfoValue = 0; //was MAX_COLUMNS_IN_GROUP_BY;
  234. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  235. break;
  236. case SQL_MAX_COLUMNS_IN_ORDER_BY:
  237. *(SWORD FAR *)rgbInfoValue = MAX_COLUMNS_IN_ORDER_BY;
  238. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  239. break;
  240. case SQL_MAX_CURSOR_NAME_LEN:
  241. *(SWORD FAR *)rgbInfoValue = MAX_CURSOR_NAME_LENGTH;
  242. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  243. break;
  244. case SQL_MAX_TABLE_NAME_LEN:
  245. *(SWORD FAR *)rgbInfoValue = ISAMMaxTableNameLength(lpdbc->lpISAM);
  246. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  247. break;
  248. case SQL_MAX_USER_NAME_LEN:
  249. *(SWORD FAR *)rgbInfoValue = MAX_USER_NAME_LENGTH;
  250. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  251. break;
  252. case SQL_NON_NULLABLE_COLUMNS:
  253. *(SWORD FAR *)rgbInfoValue = SQL_NNC_NON_NULL;
  254. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  255. break;
  256. case SQL_NULL_COLLATION:
  257. *(SWORD FAR *)rgbInfoValue = SQL_NC_LOW;
  258. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  259. break;
  260. case SQL_ODBC_API_CONFORMANCE:
  261. *(SWORD FAR *)rgbInfoValue = SQL_OAC_LEVEL1;
  262. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  263. break;
  264. case SQL_ODBC_SAG_CLI_CONFORMANCE:
  265. *(SWORD FAR *)rgbInfoValue = SQL_OSCC_COMPLIANT;
  266. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  267. break;
  268. case SQL_ODBC_SQL_CONFORMANCE:
  269. *(SWORD FAR *)rgbInfoValue = SQL_OSC_MINIMUM;
  270. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  271. break;
  272. case SQL_QUALIFIER_LOCATION:
  273. *(SWORD FAR *)rgbInfoValue = SQL_QL_START;
  274. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  275. break;
  276. case SQL_TXN_CAPABLE:
  277. *(SWORD FAR *)rgbInfoValue = lpdbc->lpISAM->fTxnCapable;
  278. if (pcbInfoValue != NULL) *pcbInfoValue = 2;
  279. break;
  280. /* INFOs that return a four byte value */
  281. case SQL_ALTER_TABLE:
  282. case SQL_BOOKMARK_PERSISTENCE:
  283. case SQL_FETCH_DIRECTION:
  284. case SQL_LOCK_TYPES:
  285. case SQL_MAX_INDEX_SIZE:
  286. case SQL_MAX_ROW_SIZE:
  287. case SQL_MAX_STATEMENT_LEN:
  288. case SQL_OWNER_USAGE:
  289. case SQL_POS_OPERATIONS:
  290. case SQL_POSITIONED_STATEMENTS:
  291. case SQL_SCROLL_CONCURRENCY:
  292. case SQL_SCROLL_OPTIONS:
  293. case SQL_STATIC_SENSITIVITY:
  294. case SQL_UNION:
  295. *(SDWORD FAR *)rgbInfoValue = 0;
  296. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  297. break;
  298. case SQL_SUBQUERIES:
  299. *(SDWORD FAR *)rgbInfoValue = SQL_SQ_CORRELATED_SUBQUERIES |
  300. SQL_SQ_COMPARISON |
  301. SQL_SQ_EXISTS |
  302. SQL_SQ_IN |
  303. SQL_SQ_QUANTIFIED;
  304. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  305. break;
  306. case SQL_QUALIFIER_USAGE:
  307. *(SDWORD FAR *)rgbInfoValue = SQL_QU_DML_STATEMENTS;
  308. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  309. break;
  310. case SQL_DEFAULT_TXN_ISOLATION:
  311. if (lpdbc->lpISAM->fTxnCapable != SQL_TC_NONE)
  312. *(SDWORD FAR *)rgbInfoValue = lpdbc->lpISAM->fDefaultTxnIsolation;
  313. else
  314. *(SDWORD FAR *)rgbInfoValue = 0;
  315. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  316. break;
  317. case SQL_TXN_ISOLATION_OPTION:
  318. if (lpdbc->lpISAM->fTxnCapable != SQL_TC_NONE)
  319. *(SDWORD FAR *)rgbInfoValue =
  320. lpdbc->lpISAM->fTxnIsolationOption;
  321. else
  322. *(SDWORD FAR *)rgbInfoValue = 0;
  323. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  324. break;
  325. case SQL_GETDATA_EXTENSIONS:
  326. *(SDWORD FAR *)rgbInfoValue = SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER |
  327. SQL_GD_BOUND;
  328. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  329. break;
  330. case SQL_MAX_CHAR_LITERAL_LEN:
  331. *(SDWORD FAR *)rgbInfoValue = MAX_CHAR_LITERAL_LENGTH;
  332. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  333. break;
  334. case SQL_MAX_BINARY_LITERAL_LEN:
  335. *(SDWORD FAR *)rgbInfoValue = 0;// was MAX_BINARY_LITERAL_LENGTH;
  336. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  337. break;
  338. case SQL_OJ_CAPABILITIES:
  339. *(SDWORD FAR *)rgbInfoValue = SQL_OJ_LEFT |
  340. SQL_OJ_NESTED |
  341. SQL_OJ_NOT_ORDERED |
  342. SQL_OJ_ALL_COMPARISON_OPS;
  343. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  344. break;
  345. case SQL_CONVERT_BIGINT:
  346. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  347. SQL_CVT_BINARY |
  348. SQL_CVT_BIT |
  349. SQL_CVT_CHAR |
  350. SQL_CVT_DECIMAL |
  351. SQL_CVT_DOUBLE |
  352. SQL_CVT_FLOAT |
  353. SQL_CVT_INTEGER |
  354. SQL_CVT_NUMERIC |
  355. SQL_CVT_REAL |
  356. SQL_CVT_SMALLINT |
  357. SQL_CVT_TINYINT |
  358. SQL_CVT_VARBINARY |
  359. SQL_CVT_VARCHAR ;
  360. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  361. break;
  362. case SQL_CONVERT_BINARY:
  363. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  364. SQL_CVT_BINARY |
  365. SQL_CVT_BIT |
  366. SQL_CVT_CHAR |
  367. SQL_CVT_DATE |
  368. SQL_CVT_DECIMAL |
  369. SQL_CVT_DOUBLE |
  370. SQL_CVT_FLOAT |
  371. SQL_CVT_INTEGER |
  372. SQL_CVT_NUMERIC |
  373. SQL_CVT_REAL |
  374. SQL_CVT_SMALLINT |
  375. SQL_CVT_TIME |
  376. SQL_CVT_TIMESTAMP |
  377. SQL_CVT_TINYINT |
  378. SQL_CVT_VARBINARY |
  379. SQL_CVT_VARCHAR ;
  380. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  381. break;
  382. case SQL_CONVERT_BIT:
  383. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  384. SQL_CVT_BINARY |
  385. SQL_CVT_BIT |
  386. SQL_CVT_CHAR |
  387. SQL_CVT_DECIMAL |
  388. SQL_CVT_DOUBLE |
  389. SQL_CVT_FLOAT |
  390. SQL_CVT_INTEGER |
  391. SQL_CVT_NUMERIC |
  392. SQL_CVT_REAL |
  393. SQL_CVT_SMALLINT |
  394. SQL_CVT_TINYINT |
  395. SQL_CVT_VARBINARY |
  396. SQL_CVT_VARCHAR ;
  397. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  398. break;
  399. case SQL_CONVERT_CHAR:
  400. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  401. SQL_CVT_BINARY |
  402. SQL_CVT_BIT |
  403. SQL_CVT_CHAR |
  404. SQL_CVT_DATE |
  405. SQL_CVT_DECIMAL |
  406. SQL_CVT_DOUBLE |
  407. SQL_CVT_FLOAT |
  408. SQL_CVT_INTEGER |
  409. SQL_CVT_NUMERIC |
  410. SQL_CVT_REAL |
  411. SQL_CVT_SMALLINT |
  412. SQL_CVT_TIME |
  413. SQL_CVT_TIMESTAMP |
  414. SQL_CVT_TINYINT |
  415. SQL_CVT_VARBINARY |
  416. SQL_CVT_VARCHAR ;
  417. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  418. break;
  419. case SQL_CONVERT_DATE:
  420. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BINARY |
  421. SQL_CVT_CHAR |
  422. SQL_CVT_DATE |
  423. SQL_CVT_TIMESTAMP |
  424. SQL_CVT_VARBINARY |
  425. SQL_CVT_VARCHAR ;
  426. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  427. break;
  428. case SQL_CONVERT_DECIMAL:
  429. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  430. SQL_CVT_BINARY |
  431. SQL_CVT_BIT |
  432. SQL_CVT_CHAR |
  433. SQL_CVT_DECIMAL |
  434. SQL_CVT_DOUBLE |
  435. SQL_CVT_FLOAT |
  436. SQL_CVT_INTEGER |
  437. SQL_CVT_NUMERIC |
  438. SQL_CVT_REAL |
  439. SQL_CVT_SMALLINT |
  440. SQL_CVT_TINYINT |
  441. SQL_CVT_VARBINARY |
  442. SQL_CVT_VARCHAR ;
  443. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  444. break;
  445. case SQL_CONVERT_DOUBLE:
  446. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  447. SQL_CVT_BINARY |
  448. SQL_CVT_BIT |
  449. SQL_CVT_CHAR |
  450. SQL_CVT_DECIMAL |
  451. SQL_CVT_DOUBLE |
  452. SQL_CVT_FLOAT |
  453. SQL_CVT_INTEGER |
  454. SQL_CVT_NUMERIC |
  455. SQL_CVT_REAL |
  456. SQL_CVT_SMALLINT |
  457. SQL_CVT_TINYINT |
  458. SQL_CVT_VARBINARY |
  459. SQL_CVT_VARCHAR ;
  460. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  461. break;
  462. case SQL_CONVERT_FLOAT:
  463. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  464. SQL_CVT_BINARY |
  465. SQL_CVT_BIT |
  466. SQL_CVT_CHAR |
  467. SQL_CVT_DECIMAL |
  468. SQL_CVT_DOUBLE |
  469. SQL_CVT_FLOAT |
  470. SQL_CVT_INTEGER |
  471. SQL_CVT_NUMERIC |
  472. SQL_CVT_REAL |
  473. SQL_CVT_SMALLINT |
  474. SQL_CVT_TINYINT |
  475. SQL_CVT_VARBINARY |
  476. SQL_CVT_VARCHAR ;
  477. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  478. break;
  479. case SQL_CONVERT_INTEGER:
  480. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  481. SQL_CVT_BINARY |
  482. SQL_CVT_BIT |
  483. SQL_CVT_CHAR |
  484. SQL_CVT_DECIMAL |
  485. SQL_CVT_DOUBLE |
  486. SQL_CVT_FLOAT |
  487. SQL_CVT_INTEGER |
  488. SQL_CVT_NUMERIC |
  489. SQL_CVT_REAL |
  490. SQL_CVT_SMALLINT |
  491. SQL_CVT_TINYINT |
  492. SQL_CVT_VARBINARY |
  493. SQL_CVT_VARCHAR ;
  494. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  495. break;
  496. case SQL_CONVERT_LONGVARBINARY:
  497. case SQL_CONVERT_LONGVARCHAR:
  498. *(SDWORD FAR *)rgbInfoValue = 0;
  499. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  500. break;
  501. case SQL_CONVERT_NUMERIC:
  502. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  503. SQL_CVT_BINARY |
  504. SQL_CVT_BIT |
  505. SQL_CVT_CHAR |
  506. SQL_CVT_DECIMAL |
  507. SQL_CVT_DOUBLE |
  508. SQL_CVT_FLOAT |
  509. SQL_CVT_INTEGER |
  510. SQL_CVT_NUMERIC |
  511. SQL_CVT_REAL |
  512. SQL_CVT_SMALLINT |
  513. SQL_CVT_TINYINT |
  514. SQL_CVT_VARBINARY |
  515. SQL_CVT_VARCHAR ;
  516. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  517. break;
  518. case SQL_CONVERT_REAL:
  519. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  520. SQL_CVT_BINARY |
  521. SQL_CVT_BIT |
  522. SQL_CVT_CHAR |
  523. SQL_CVT_DECIMAL |
  524. SQL_CVT_DOUBLE |
  525. SQL_CVT_FLOAT |
  526. SQL_CVT_INTEGER |
  527. SQL_CVT_NUMERIC |
  528. SQL_CVT_REAL |
  529. SQL_CVT_SMALLINT |
  530. SQL_CVT_TINYINT |
  531. SQL_CVT_VARBINARY |
  532. SQL_CVT_VARCHAR ;
  533. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  534. break;
  535. case SQL_CONVERT_SMALLINT:
  536. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  537. SQL_CVT_BINARY |
  538. SQL_CVT_BIT |
  539. SQL_CVT_CHAR |
  540. SQL_CVT_DECIMAL |
  541. SQL_CVT_DOUBLE |
  542. SQL_CVT_FLOAT |
  543. SQL_CVT_INTEGER |
  544. SQL_CVT_NUMERIC |
  545. SQL_CVT_REAL |
  546. SQL_CVT_SMALLINT |
  547. SQL_CVT_TINYINT |
  548. SQL_CVT_VARBINARY |
  549. SQL_CVT_VARCHAR ;
  550. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  551. break;
  552. case SQL_CONVERT_TIME:
  553. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BINARY |
  554. SQL_CVT_CHAR |
  555. SQL_CVT_TIME |
  556. SQL_CVT_TIMESTAMP |
  557. SQL_CVT_VARBINARY |
  558. SQL_CVT_VARCHAR ;
  559. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  560. break;
  561. case SQL_CONVERT_TIMESTAMP:
  562. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BINARY |
  563. SQL_CVT_CHAR |
  564. SQL_CVT_DATE |
  565. SQL_CVT_TIME |
  566. SQL_CVT_TIMESTAMP |
  567. SQL_CVT_VARBINARY |
  568. SQL_CVT_VARCHAR ;
  569. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  570. break;
  571. case SQL_CONVERT_TINYINT:
  572. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  573. SQL_CVT_BINARY |
  574. SQL_CVT_BIT |
  575. SQL_CVT_CHAR |
  576. SQL_CVT_DECIMAL |
  577. SQL_CVT_DOUBLE |
  578. SQL_CVT_FLOAT |
  579. SQL_CVT_INTEGER |
  580. SQL_CVT_NUMERIC |
  581. SQL_CVT_REAL |
  582. SQL_CVT_SMALLINT |
  583. SQL_CVT_TINYINT |
  584. SQL_CVT_VARBINARY |
  585. SQL_CVT_VARCHAR ;
  586. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  587. break;
  588. case SQL_CONVERT_VARBINARY:
  589. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  590. SQL_CVT_BINARY |
  591. SQL_CVT_BIT |
  592. SQL_CVT_CHAR |
  593. SQL_CVT_DATE |
  594. SQL_CVT_DECIMAL |
  595. SQL_CVT_DOUBLE |
  596. SQL_CVT_FLOAT |
  597. SQL_CVT_INTEGER |
  598. SQL_CVT_NUMERIC |
  599. SQL_CVT_REAL |
  600. SQL_CVT_SMALLINT |
  601. SQL_CVT_TIME |
  602. SQL_CVT_TIMESTAMP |
  603. SQL_CVT_TINYINT |
  604. SQL_CVT_VARBINARY |
  605. SQL_CVT_VARCHAR ;
  606. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  607. break;
  608. case SQL_CONVERT_VARCHAR:
  609. *(SDWORD FAR *)rgbInfoValue = SQL_CVT_BIGINT |
  610. SQL_CVT_BINARY |
  611. SQL_CVT_BIT |
  612. SQL_CVT_CHAR |
  613. SQL_CVT_DATE |
  614. SQL_CVT_DECIMAL |
  615. SQL_CVT_DOUBLE |
  616. SQL_CVT_FLOAT |
  617. SQL_CVT_INTEGER |
  618. SQL_CVT_NUMERIC |
  619. SQL_CVT_REAL |
  620. SQL_CVT_SMALLINT |
  621. SQL_CVT_TIME |
  622. SQL_CVT_TIMESTAMP |
  623. SQL_CVT_TINYINT |
  624. SQL_CVT_VARBINARY |
  625. SQL_CVT_VARCHAR ;
  626. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  627. break;
  628. case SQL_CONVERT_FUNCTIONS:
  629. *(SDWORD FAR *)rgbInfoValue = SQL_FN_CVT_CONVERT;
  630. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  631. break;
  632. case SQL_NUMERIC_FUNCTIONS:
  633. *(SDWORD FAR *)rgbInfoValue = SQL_FN_NUM_ABS |
  634. SQL_FN_NUM_ACOS |
  635. SQL_FN_NUM_ASIN |
  636. SQL_FN_NUM_ATAN |
  637. SQL_FN_NUM_ATAN2 |
  638. SQL_FN_NUM_CEILING |
  639. SQL_FN_NUM_COS |
  640. SQL_FN_NUM_COT |
  641. SQL_FN_NUM_DEGREES |
  642. SQL_FN_NUM_EXP |
  643. SQL_FN_NUM_FLOOR |
  644. SQL_FN_NUM_LOG |
  645. SQL_FN_NUM_LOG10 |
  646. SQL_FN_NUM_MOD |
  647. SQL_FN_NUM_PI |
  648. SQL_FN_NUM_POWER |
  649. SQL_FN_NUM_RADIANS |
  650. SQL_FN_NUM_RAND |
  651. SQL_FN_NUM_ROUND |
  652. SQL_FN_NUM_SIGN |
  653. SQL_FN_NUM_SIN |
  654. SQL_FN_NUM_SQRT |
  655. SQL_FN_NUM_TRUNCATE |
  656. SQL_FN_NUM_TAN ;
  657. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  658. break;
  659. case SQL_STRING_FUNCTIONS:
  660. *(SDWORD FAR *)rgbInfoValue = SQL_FN_STR_ASCII |
  661. SQL_FN_STR_CHAR |
  662. SQL_FN_STR_CONCAT |
  663. SQL_FN_STR_DIFFERENCE |
  664. SQL_FN_STR_INSERT |
  665. SQL_FN_STR_LCASE |
  666. SQL_FN_STR_LEFT |
  667. SQL_FN_STR_LENGTH |
  668. SQL_FN_STR_LOCATE |
  669. SQL_FN_STR_LOCATE_2 |
  670. SQL_FN_STR_LTRIM |
  671. SQL_FN_STR_REPEAT |
  672. SQL_FN_STR_REPLACE |
  673. SQL_FN_STR_RIGHT |
  674. SQL_FN_STR_RTRIM |
  675. SQL_FN_STR_SOUNDEX |
  676. SQL_FN_STR_SPACE |
  677. SQL_FN_STR_SUBSTRING |
  678. SQL_FN_STR_UCASE ;
  679. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  680. break;
  681. case SQL_SYSTEM_FUNCTIONS:
  682. *(SDWORD FAR *)rgbInfoValue = SQL_FN_SYS_DBNAME |
  683. SQL_FN_SYS_IFNULL |
  684. SQL_FN_SYS_USERNAME ;
  685. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  686. break;
  687. case SQL_TIMEDATE_ADD_INTERVALS:
  688. case SQL_TIMEDATE_DIFF_INTERVALS:
  689. *(SDWORD FAR *)rgbInfoValue = /* SQL_FN_TSI_FRAC_SECOND | */
  690. SQL_FN_TSI_SECOND |
  691. SQL_FN_TSI_MINUTE |
  692. SQL_FN_TSI_HOUR |
  693. SQL_FN_TSI_DAY |
  694. SQL_FN_TSI_WEEK |
  695. SQL_FN_TSI_MONTH |
  696. SQL_FN_TSI_QUARTER |
  697. SQL_FN_TSI_YEAR ;
  698. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  699. break;
  700. case SQL_TIMEDATE_FUNCTIONS:
  701. *(SDWORD FAR *)rgbInfoValue = SQL_FN_TD_CURDATE |
  702. SQL_FN_TD_CURTIME |
  703. SQL_FN_TD_DAYNAME |
  704. SQL_FN_TD_DAYOFMONTH |
  705. SQL_FN_TD_DAYOFWEEK |
  706. SQL_FN_TD_DAYOFYEAR |
  707. SQL_FN_TD_HOUR |
  708. SQL_FN_TD_MINUTE |
  709. SQL_FN_TD_MONTH |
  710. SQL_FN_TD_MONTHNAME |
  711. SQL_FN_TD_NOW |
  712. SQL_FN_TD_QUARTER |
  713. SQL_FN_TD_SECOND |
  714. SQL_FN_TD_TIMESTAMPADD |
  715. SQL_FN_TD_TIMESTAMPDIFF |
  716. SQL_FN_TD_WEEK |
  717. SQL_FN_TD_YEAR;
  718. if (pcbInfoValue != NULL) *pcbInfoValue = 4;
  719. break;
  720. default:
  721. lpdbc->errcode = ERR_NOTSUPPORTED;
  722. return SQL_ERROR;
  723. }
  724. if (lpdbc->errcode == ERR_DATATRUNCATED)
  725. return SQL_SUCCESS_WITH_INFO;
  726. if (lpdbc->errcode == ERR_ISAM)
  727. return SQL_ERROR;
  728. return SQL_SUCCESS;
  729. }
  730. /***************************************************************************/
  731. RETCODE SQL_API SQLGetTypeInfo(
  732. HSTMT hstmt,
  733. SWORD fSqlType)
  734. {
  735. LPSTMT lpstmt;
  736. /* Get statement handle */
  737. lpstmt = (LPSTMT) hstmt;
  738. lpstmt->errcode = ERR_SUCCESS;
  739. //To make guarentee Ole is initialized per thread
  740. COleInitializationManager myOleManager;
  741. MyImpersonator im (lpstmt, "SQLGetTypeInfo");
  742. /* Error if in the middle of a statement already */
  743. if (lpstmt->fStmtType != STMT_TYPE_NONE) {
  744. lpstmt->errcode = ERR_CURSORSTATE;
  745. return SQL_ERROR;
  746. }
  747. if (lpstmt->fNeedData) {
  748. lpstmt->errcode = ERR_CURSORSTATE;
  749. return SQL_ERROR;
  750. }
  751. /* Free previously prepared statement if any */
  752. if (lpstmt->lpSqlStmt != NULL) {
  753. FreeTree(lpstmt->lpSqlStmt);
  754. lpstmt->lpSqlStmt = NULL;
  755. lpstmt->fPreparedSql = FALSE;
  756. if (lpstmt->lpISAMStatement != NULL) {
  757. ISAMFreeStatement(lpstmt->lpISAMStatement);
  758. lpstmt->lpISAMStatement = NULL;
  759. }
  760. lpstmt->fNeedData = FALSE;
  761. lpstmt->idxParameter = NO_SQLNODE;
  762. lpstmt->cbParameterOffset = -1;
  763. lpstmt->cRowCount = -1;
  764. }
  765. /* Set type of table */
  766. lpstmt->fStmtType = STMT_TYPE_TYPEINFO;
  767. lpstmt->fStmtSubtype = STMT_SUBTYPE_NONE;
  768. /* Remember which type to get information for */
  769. lpstmt->fSqlType = fSqlType;
  770. /* So far no types returned */
  771. lpstmt->irow = BEFORE_FIRST_ROW;
  772. /* Count of rows is not available */
  773. lpstmt->cRowCount = -1;
  774. /* So far no column read */
  775. lpstmt->icol = NO_COLUMN;
  776. lpstmt->cbOffset = 0;
  777. return SQL_SUCCESS;
  778. }
  779. /***************************************************************************/
  780. RETCODE SQL_API SQLGetFunctions(
  781. HDBC hdbc,
  782. UWORD fFunction,
  783. UWORD FAR *pfExists)
  784. {
  785. LPDBC lpdbc;
  786. UWORD i;
  787. lpdbc = (LPDBC) hdbc;
  788. lpdbc->errcode = ERR_SUCCESS;
  789. //To make guarentee Ole is initialized per thread
  790. COleInitializationManager myOleManager;
  791. MyImpersonator im (lpdbc, "SQLGetFunctions");
  792. switch (fFunction) {
  793. case SQL_API_ALL_FUNCTIONS:
  794. pfExists[SQL_API_ALL_FUNCTIONS] = FALSE;
  795. for (i=1; i < 100; i++)
  796. SQLGetFunctions(hdbc, i, &(pfExists[i]));
  797. break;
  798. case SQL_API_SQLALLOCENV:
  799. case SQL_API_SQLALLOCCONNECT:
  800. case SQL_API_SQLALLOCSTMT:
  801. case SQL_API_SQLBINDCOL:
  802. case SQL_API_SQLBINDPARAMETER:
  803. case SQL_API_SQLCANCEL:
  804. case SQL_API_SQLCOLATTRIBUTES:
  805. case SQL_API_SQLCOLUMNS:
  806. case SQL_API_SQLCONNECT:
  807. case SQL_API_SQLDATASOURCES:
  808. case SQL_API_SQLDESCRIBECOL:
  809. case SQL_API_SQLDISCONNECT:
  810. case SQL_API_SQLDRIVERCONNECT:
  811. case SQL_API_SQLDRIVERS:
  812. case SQL_API_SQLERROR:
  813. case SQL_API_SQLEXECDIRECT:
  814. case SQL_API_SQLEXECUTE:
  815. case SQL_API_SQLFETCH:
  816. case SQL_API_SQLFOREIGNKEYS:
  817. case SQL_API_SQLFREEENV:
  818. case SQL_API_SQLFREECONNECT:
  819. case SQL_API_SQLFREESTMT:
  820. case SQL_API_SQLGETCONNECTOPTION:
  821. case SQL_API_SQLGETDATA:
  822. case SQL_API_SQLGETINFO:
  823. case SQL_API_SQLGETCURSORNAME:
  824. case SQL_API_SQLGETFUNCTIONS:
  825. case SQL_API_SQLGETSTMTOPTION:
  826. case SQL_API_SQLGETTYPEINFO:
  827. case SQL_API_SQLMORERESULTS:
  828. case SQL_API_SQLNUMRESULTCOLS:
  829. case SQL_API_SQLPARAMDATA:
  830. case SQL_API_SQLPUTDATA:
  831. case SQL_API_SQLPREPARE:
  832. case SQL_API_SQLROWCOUNT:
  833. case SQL_API_SQLSETCONNECTOPTION:
  834. case SQL_API_SQLSETCURSORNAME:
  835. case SQL_API_SQLSETSTMTOPTION:
  836. case SQL_API_SQLSPECIALCOLUMNS:
  837. case SQL_API_SQLSTATISTICS:
  838. case SQL_API_SQLTABLES:
  839. // case SQL_API_SQLTRANSACT:
  840. *pfExists = TRUE;
  841. break;
  842. default:
  843. *pfExists = FALSE;
  844. break;
  845. }
  846. return SQL_SUCCESS;
  847. }
  848. /***************************************************************************/