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.

429 lines
12 KiB

  1. /***************************************************************************/
  2. /* OPTIONS.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 "wbemidl.h"
  10. #include <comdef.h>
  11. //smart pointer
  12. _COM_SMARTPTR_TYPEDEF(IWbemServices, IID_IWbemServices);
  13. _COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, IID_IEnumWbemClassObject);
  14. //_COM_SMARTPTR_TYPEDEF(IWbemContext, IID_IWbemContext );
  15. _COM_SMARTPTR_TYPEDEF(IWbemLocator, IID_IWbemLocator);
  16. #include "drdbdr.h"
  17. /***************************************************************************/
  18. RETCODE SQL_API SQLSetConnectOption(
  19. HDBC hdbc,
  20. UWORD fOption,
  21. UDWORD vParam)
  22. {
  23. LPDBC lpdbc;
  24. LPSTMT lpstmt;
  25. SWORD err;
  26. /* Get connection handle */
  27. lpdbc = (LPDBC) hdbc;
  28. lpdbc->errcode = ERR_SUCCESS;
  29. //To make guarentee Ole is initialized per thread
  30. COleInitializationManager myOleManager;
  31. MyImpersonator im (lpdbc, "SQLSetConnectOption");
  32. /* Set the option value */
  33. switch (fOption) {
  34. case SQL_ACCESS_MODE:
  35. break;
  36. case SQL_AUTOCOMMIT:
  37. if (lpdbc->lpISAM->fTxnCapable == SQL_TC_NONE) {
  38. if (vParam != SQL_AUTOCOMMIT_ON)
  39. lpdbc->errcode = ERR_NOTCAPABLE;
  40. }
  41. else {
  42. switch (vParam) {
  43. case SQL_AUTOCOMMIT_ON:
  44. if (!(lpdbc->fAutoCommitTxn)) {
  45. err = SQLTransact(SQL_NULL_HENV, (HDBC)lpdbc, SQL_COMMIT);
  46. if ((err != SQL_SUCCESS)&&(err != SQL_SUCCESS_WITH_INFO))
  47. return err;
  48. lpdbc->fAutoCommitTxn = TRUE;
  49. }
  50. break;
  51. case SQL_AUTOCOMMIT_OFF:
  52. lpdbc->fAutoCommitTxn = FALSE;
  53. break;
  54. default:
  55. lpdbc->errcode = ERR_NOTCAPABLE;
  56. break;
  57. }
  58. }
  59. break;
  60. case SQL_CURRENT_QUALIFIER:
  61. // check that the namespace exists on the connection
  62. CNamespace* pa;
  63. if (lpdbc->lpISAM->pNamespaceMap->Lookup ((LPSTR)vParam,
  64. (CObject*&)pa))
  65. {
  66. if (!ISAMSetDatabase (lpdbc->lpISAM, (LPUSTR) vParam))
  67. lpdbc->errcode = ERR_INVALIDQUALIFIER;
  68. }
  69. else
  70. {
  71. lpdbc->errcode = ERR_INVALIDQUALIFIER;
  72. }
  73. break;
  74. case SQL_LOGIN_TIMEOUT:
  75. if (vParam != 0)
  76. lpdbc->errcode = ERR_NOTCAPABLE;
  77. break;
  78. case SQL_ODBC_CURSORS:
  79. lpdbc->errcode = ERR_NOTCAPABLE;
  80. break;
  81. case SQL_OPT_TRACE:
  82. if (vParam != SQL_OPT_TRACE_OFF)
  83. lpdbc->errcode = ERR_NOTCAPABLE;
  84. break;
  85. case SQL_OPT_TRACEFILE:
  86. lpdbc->errcode = ERR_NOTCAPABLE;
  87. break;
  88. case SQL_PACKET_SIZE:
  89. lpdbc->errcode = ERR_NOTCAPABLE;
  90. break;
  91. case SQL_QUIET_MODE:
  92. if ((HWND) vParam != NULL)
  93. lpdbc->errcode = ERR_NOTCAPABLE;
  94. break;
  95. case SQL_TRANSLATE_DLL:
  96. if ((LPSTR) vParam != NULL)
  97. lpdbc->errcode = ERR_NOTCAPABLE;
  98. break;
  99. case SQL_TRANSLATE_OPTION:
  100. lpdbc->errcode = ERR_NOTCAPABLE;
  101. break;
  102. case SQL_TXN_ISOLATION:
  103. if (lpdbc->lpISAM->fTxnCapable == SQL_TC_NONE)
  104. lpdbc->errcode = ERR_NOTCAPABLE;
  105. else if (lpdbc->fTxnIsolation != (SDWORD) vParam) {
  106. /* If transaction in progress, fail */
  107. for (lpstmt = lpdbc->lpstmts;
  108. lpstmt != NULL;
  109. lpstmt = lpstmt->lpNext) {
  110. if (lpstmt->fISAMTxnStarted) {
  111. lpdbc->errcode = ERR_TXNINPROGRESS;
  112. return SQL_ERROR;
  113. }
  114. }
  115. /* Set the isolation mode */
  116. lpdbc->errcode = ISAMSetTxnIsolation(lpdbc->lpISAM, vParam);
  117. if (lpdbc->errcode != NO_ISAM_ERR)
  118. return SQL_ERROR;
  119. /* Save our own copy of the new state */
  120. lpdbc->fTxnIsolation = vParam;
  121. lpdbc->errcode = ERR_SUCCESS;
  122. }
  123. break;
  124. /* (the following are statement options) */
  125. case SQL_ASYNC_ENABLE:
  126. if (vParam != SQL_ASYNC_ENABLE_OFF)
  127. lpdbc->errcode = ERR_NOTCAPABLE;
  128. break;
  129. case SQL_BIND_TYPE:
  130. lpdbc->errcode = ERR_NOTCAPABLE;
  131. break;
  132. case SQL_CONCURRENCY:
  133. lpdbc->errcode = ERR_NOTCAPABLE;
  134. break;
  135. case SQL_CURSOR_TYPE:
  136. lpdbc->errcode = ERR_NOTCAPABLE;
  137. break;
  138. case SQL_KEYSET_SIZE:
  139. lpdbc->errcode = ERR_NOTCAPABLE;
  140. break;
  141. case SQL_MAX_LENGTH:
  142. if (vParam != 0)
  143. lpdbc->errcode = ERR_NOTCAPABLE;
  144. break;
  145. case SQL_MAX_ROWS:
  146. if (vParam != 0)
  147. lpdbc->errcode = ERR_NOTCAPABLE;
  148. break;
  149. case SQL_NOSCAN:
  150. if (vParam != SQL_NOSCAN_OFF)
  151. lpdbc->errcode = ERR_NOTCAPABLE;
  152. break;
  153. case SQL_QUERY_TIMEOUT:
  154. if (vParam != 0)
  155. lpdbc->errcode = ERR_NOTCAPABLE;
  156. break;
  157. case SQL_RETRIEVE_DATA:
  158. lpdbc->errcode = ERR_NOTCAPABLE;
  159. break;
  160. case SQL_ROWSET_SIZE:
  161. lpdbc->errcode = ERR_NOTCAPABLE;
  162. break;
  163. case SQL_SIMULATE_CURSOR:
  164. lpdbc->errcode = ERR_NOTCAPABLE;
  165. break;
  166. case SQL_USE_BOOKMARKS:
  167. if (vParam != SQL_UB_OFF)
  168. lpdbc->errcode = ERR_NOTCAPABLE;
  169. break;
  170. default:
  171. lpdbc->errcode = ERR_NOTCAPABLE;
  172. break;
  173. }
  174. if (lpdbc->errcode != ERR_SUCCESS)
  175. return SQL_ERROR;
  176. return SQL_SUCCESS;
  177. }
  178. /***************************************************************************/
  179. RETCODE SQL_API SQLSetStmtOption(
  180. HSTMT hstmt,
  181. UWORD fOption,
  182. UDWORD vParam)
  183. {
  184. LPSTMT lpstmt;
  185. /* Get statement handle */
  186. lpstmt = (LPSTMT) hstmt;
  187. lpstmt->errcode = ERR_SUCCESS;
  188. //To make guarentee Ole is initialized per thread
  189. COleInitializationManager myOleManager;
  190. MyImpersonator im (lpstmt, "SQLSetStmtOption");
  191. /* Error if bad option */
  192. /* Set the option value */
  193. switch (fOption) {
  194. case SQL_ASYNC_ENABLE:
  195. {
  196. switch (vParam)
  197. {
  198. case SQL_ASYNC_ENABLE_OFF:
  199. case SQL_ASYNC_ENABLE_ON:
  200. lpstmt->fSyncMode = vParam;
  201. break;
  202. default:
  203. lpstmt->errcode = ERR_NOTCAPABLE;
  204. break;
  205. }
  206. }
  207. break;
  208. case SQL_BIND_TYPE:
  209. lpstmt->errcode = ERR_NOTCAPABLE;
  210. break;
  211. case SQL_CONCURRENCY:
  212. lpstmt->errcode = ERR_NOTCAPABLE;
  213. break;
  214. case SQL_CURSOR_TYPE:
  215. lpstmt->errcode = ERR_NOTCAPABLE;
  216. break;
  217. case SQL_KEYSET_SIZE:
  218. lpstmt->errcode = ERR_NOTCAPABLE;
  219. break;
  220. case SQL_MAX_LENGTH:
  221. if (vParam != SQL_ASYNC_ENABLE_OFF)
  222. lpstmt->errcode = ERR_NOTCAPABLE;
  223. break;
  224. case SQL_MAX_ROWS:
  225. if (vParam != 0)
  226. lpstmt->errcode = ERR_NOTCAPABLE;
  227. break;
  228. case SQL_NOSCAN:
  229. if (vParam != SQL_NOSCAN_OFF)
  230. lpstmt->errcode = ERR_NOTCAPABLE;
  231. break;
  232. case SQL_QUERY_TIMEOUT:
  233. if (vParam != 0)
  234. lpstmt->errcode = ERR_NOTCAPABLE;
  235. break;
  236. case SQL_RETRIEVE_DATA:
  237. lpstmt->errcode = ERR_NOTCAPABLE;
  238. break;
  239. case SQL_ROWSET_SIZE:
  240. lpstmt->errcode = ERR_NOTCAPABLE;
  241. break;
  242. case SQL_SIMULATE_CURSOR:
  243. lpstmt->errcode = ERR_NOTCAPABLE;
  244. break;
  245. case SQL_USE_BOOKMARKS:
  246. if (vParam != SQL_UB_OFF)
  247. lpstmt->errcode = ERR_NOTCAPABLE;
  248. break;
  249. default:
  250. lpstmt->errcode = ERR_NOTCAPABLE;
  251. break;
  252. }
  253. if (lpstmt->errcode != ERR_SUCCESS)
  254. return SQL_ERROR;
  255. return SQL_SUCCESS;
  256. }
  257. /***************************************************************************/
  258. RETCODE SQL_API SQLGetConnectOption(
  259. HDBC hdbc,
  260. UWORD fOption,
  261. PTR pvParam)
  262. {
  263. LPDBC lpdbc;
  264. /* Get connection handle */
  265. lpdbc = (LPDBC) hdbc;
  266. lpdbc->errcode = ERR_SUCCESS;
  267. //To make guarentee Ole is initialized per thread
  268. COleInitializationManager myOleManager;
  269. MyImpersonator im (lpdbc, "SQLGetConnectOption");
  270. /* Return the option value */
  271. switch (fOption) {
  272. case SQL_ACCESS_MODE:
  273. *((SDWORD FAR *) pvParam) = SQL_MODE_READ_WRITE;
  274. break;
  275. case SQL_AUTOCOMMIT:
  276. if (lpdbc->fAutoCommitTxn)
  277. *((SDWORD FAR *) pvParam) = SQL_AUTOCOMMIT_ON;
  278. else
  279. *((SDWORD FAR *) pvParam) = SQL_AUTOCOMMIT_OFF;
  280. break;
  281. case SQL_CURRENT_QUALIFIER:
  282. s_lstrcpy((LPSTR) pvParam, ISAMDatabase(lpdbc->lpISAM));
  283. break;
  284. case SQL_LOGIN_TIMEOUT:
  285. *((SDWORD FAR *) pvParam) = 0;
  286. break;
  287. case SQL_ODBC_CURSORS:
  288. lpdbc->errcode = ERR_NOTCAPABLE;
  289. break;
  290. case SQL_OPT_TRACE:
  291. *((SDWORD FAR *) pvParam) = SQL_OPT_TRACE_OFF;
  292. break;
  293. case SQL_OPT_TRACEFILE:
  294. lstrcpy((LPSTR) pvParam, "");
  295. break;
  296. case SQL_PACKET_SIZE:
  297. lpdbc->errcode = ERR_NOTCAPABLE;
  298. break;
  299. case SQL_QUIET_MODE:
  300. *((SDWORD FAR *) pvParam) = (SDWORD) NULL;
  301. break;
  302. case SQL_TRANSLATE_DLL:
  303. lstrcpy((LPSTR) pvParam, "");
  304. break;
  305. case SQL_TRANSLATE_OPTION:
  306. *((SDWORD FAR *) pvParam) = 0;
  307. break;
  308. case SQL_TXN_ISOLATION:
  309. if (lpdbc->lpISAM->fTxnCapable != SQL_TC_NONE)
  310. *((SDWORD FAR *) pvParam) = lpdbc->fTxnIsolation;
  311. else
  312. lpdbc->errcode = ERR_NOTCAPABLE;
  313. break;
  314. default:
  315. lpdbc->errcode = ERR_NOTCAPABLE;
  316. break;
  317. }
  318. if (lpdbc->errcode != ERR_SUCCESS)
  319. return SQL_ERROR;
  320. return SQL_SUCCESS;
  321. }
  322. /***************************************************************************/
  323. RETCODE SQL_API SQLGetStmtOption(
  324. HSTMT hstmt,
  325. UWORD fOption,
  326. PTR pvParam)
  327. {
  328. LPSTMT lpstmt;
  329. //To make guarentee Ole is initialized per thread
  330. COleInitializationManager myOleManager;
  331. /* Get statement handle */
  332. lpstmt = (LPSTMT) hstmt;
  333. lpstmt->errcode = ERR_SUCCESS;
  334. MyImpersonator im (lpstmt, "SQLGetStmtOption");
  335. /* Get the option value */
  336. switch (fOption) {
  337. case SQL_ASYNC_ENABLE:
  338. *((SDWORD FAR *) pvParam) = lpstmt->fSyncMode;
  339. break;
  340. case SQL_BIND_TYPE:
  341. lpstmt->errcode = ERR_NOTCAPABLE;
  342. break;
  343. case SQL_CONCURRENCY:
  344. lpstmt->errcode = ERR_NOTCAPABLE;
  345. break;
  346. case SQL_CURSOR_TYPE:
  347. lpstmt->errcode = ERR_NOTCAPABLE;
  348. break;
  349. case SQL_KEYSET_SIZE:
  350. lpstmt->errcode = ERR_NOTCAPABLE;
  351. break;
  352. case SQL_MAX_LENGTH:
  353. *((SDWORD FAR *) pvParam) = 0;
  354. break;
  355. case SQL_MAX_ROWS:
  356. *((SDWORD FAR *) pvParam) = 0;
  357. break;
  358. case SQL_NOSCAN:
  359. *((SDWORD FAR *) pvParam) = SQL_NOSCAN_OFF;
  360. break;
  361. case SQL_QUERY_TIMEOUT:
  362. *((SDWORD FAR *) pvParam) = 0;
  363. break;
  364. case SQL_RETRIEVE_DATA:
  365. lpstmt->errcode = ERR_NOTCAPABLE;
  366. break;
  367. case SQL_ROWSET_SIZE:
  368. lpstmt->errcode = ERR_NOTCAPABLE;
  369. break;
  370. case SQL_SIMULATE_CURSOR:
  371. lpstmt->errcode = ERR_NOTCAPABLE;
  372. break;
  373. case SQL_USE_BOOKMARKS:
  374. lpstmt->errcode = ERR_NOTCAPABLE;
  375. break;
  376. case SQL_GET_BOOKMARK:
  377. lpstmt->errcode = ERR_NOTCAPABLE;
  378. break;
  379. case SQL_ROW_NUMBER:
  380. *((SDWORD FAR *) pvParam) = 0;
  381. break;
  382. default:
  383. lpstmt->errcode = ERR_NOTCAPABLE;
  384. break;
  385. }
  386. if (lpstmt->errcode != ERR_SUCCESS)
  387. return SQL_ERROR;
  388. return SQL_SUCCESS;
  389. }
  390. /***************************************************************************/