]> git.saurik.com Git - wxWidgets.git/blame - src/iodbc/catalog.c
Small doc corrections
[wxWidgets.git] / src / iodbc / catalog.c
CommitLineData
cd5bf2a6
RR
1/*
2 * catalog.c
3 *
4 * $Id$
5 *
6 * Catalog functions
7 *
8 * The iODBC driver manager.
9 *
10 * Copyright (C) 1995 by Ke Jin <kejin@empress.com>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#include <config.h>
28
29#include <isql.h>
30#include <isqlext.h>
31
32#include <dlproc.h>
33
34#include <herr.h>
35#include <henv.h>
36#include <hdbc.h>
37#include <hstmt.h>
38
39#include <itrace.h>
40
41static RETCODE
42_iodbcdm_cata_state_ok (
43 HSTMT hstmt,
44 int fidx)
1a6944fd
RR
45/* check state for executing catalog functions */
46{
cd5bf2a6
RR
47 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
48 int sqlstat = en_00000;
49
50 if (pstmt->asyn_on == en_NullProc)
51 {
52 switch (pstmt->state)
53 {
54 case en_stmt_needdata:
55 case en_stmt_mustput:
56 case en_stmt_canput:
57 sqlstat = en_S1010;
58 break;
59
60 case en_stmt_fetched:
61 case en_stmt_xfetched:
62 sqlstat = en_24000;
63 break;
64
65 default:
66 break;
67 }
68 }
69 else if (pstmt->asyn_on != fidx)
70 {
71 sqlstat = en_S1010;
72 }
73
74 if (sqlstat != en_00000)
75 {
76 PUSHSQLERR (pstmt->herr, sqlstat);
77
78 return SQL_ERROR;
79 }
80
81 return SQL_SUCCESS;
1a6944fd
RR
82}
83
cd5bf2a6
RR
84
85static RETCODE
86_iodbcdm_cata_state_tr (
87 HSTMT hstmt,
88 int fidx,
89 RETCODE result)
1a6944fd
RR
90/* state transition for catalog function */
91{
cd5bf2a6
RR
92 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
93 DBC_t FAR *pdbc;
94
95 pdbc = (DBC_t FAR *) (pstmt->hdbc);
96
97 if (pstmt->asyn_on == fidx)
98 {
99 switch (result)
100 {
101 case SQL_SUCCESS:
102 case SQL_SUCCESS_WITH_INFO:
103 case SQL_ERROR:
104 pstmt->asyn_on = en_NullProc;
105 break;
106
107 case SQL_STILL_EXECUTING:
108 default:
109 return result;
110 }
111 }
112
113 if (pstmt->state <= en_stmt_executed)
114 {
115 switch (result)
116 {
117 case SQL_SUCCESS:
118 case SQL_SUCCESS_WITH_INFO:
119 pstmt->state = en_stmt_cursoropen;
120 break;
121
122 case SQL_ERROR:
123 pstmt->state = en_stmt_allocated;
124 pstmt->prep_state = 0;
125 break;
126
127 case SQL_STILL_EXECUTING:
128 pstmt->asyn_on = fidx;
129 break;
130
131 default:
132 break;
133 }
134 }
135
136 return result;
1a6944fd
RR
137}
138
cd5bf2a6
RR
139
140RETCODE SQL_API
141SQLGetTypeInfo (
142 HSTMT hstmt,
143 SWORD fSqlType)
1a6944fd 144{
cd5bf2a6
RR
145 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
146 HPROC hproc = SQL_NULL_HPROC;
147 int sqlstat = en_00000;
148 RETCODE retcode;
149
150 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
151 {
152 return SQL_INVALID_HANDLE;
153 }
154
155 for (;;)
156 {
157 if (fSqlType > SQL_TYPE_MAX)
158 {
159 sqlstat = en_S1004;
160 break;
161 }
162
163 /* Note: SQL_TYPE_DRIVER_START is a negative number So, we use ">" */
164 if (fSqlType < SQL_TYPE_MIN && fSqlType > SQL_TYPE_DRIVER_START)
165 {
166 sqlstat = en_S1004;
167 break;
168 }
169
170 retcode = _iodbcdm_cata_state_ok (hstmt, en_GetTypeInfo);
171
172 if (retcode != SQL_SUCCESS)
173 {
174 return SQL_ERROR;
175 }
176
177 hproc = _iodbcdm_getproc (pstmt->hdbc, en_GetTypeInfo);
178
179 if (hproc == SQL_NULL_HPROC)
180 {
181 sqlstat = en_IM001;
182 break;
183 }
184
185 sqlstat = en_00000;
186 if (1) /* turn off solaris warning message */
187 break;
188 }
189
190 if (sqlstat != en_00000)
191 {
192 PUSHSQLERR (pstmt->herr, sqlstat);
193
194 return SQL_ERROR;
195 }
196
197 CALL_DRIVER ( pstmt->hdbc, retcode, hproc, en_GetTypeInfo,
198 (pstmt->dhstmt, fSqlType))
199
200 return _iodbcdm_cata_state_tr (hstmt, en_GetTypeInfo, retcode);
1a6944fd
RR
201}
202
cd5bf2a6
RR
203
204RETCODE SQL_API
205SQLSpecialColumns (
206 HSTMT hstmt,
207 UWORD fColType,
208 UCHAR FAR * szTableQualifier,
209 SWORD cbTableQualifier,
210 UCHAR FAR * szTableOwner,
211 SWORD cbTableOwner,
212 UCHAR FAR * szTableName,
213 SWORD cbTableName,
214 UWORD fScope,
215 UWORD fNullable)
1a6944fd 216{
cd5bf2a6
RR
217 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
218 HPROC hproc = SQL_NULL_HPROC;
219 RETCODE retcode;
220 int sqlstat = en_00000;
221
222 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
223 {
224 return SQL_INVALID_HANDLE;
225 }
226
227 for (;;)
228 {
229 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
230 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
231 || (cbTableName < 0 && cbTableName != SQL_NTS))
232 {
233 sqlstat = en_S1090;
234 break;
235 }
236
237 if (fColType != SQL_BEST_ROWID && fColType != SQL_ROWVER)
238 {
239 sqlstat = en_S1097;
240 break;
241 }
242
243 if (fScope != SQL_SCOPE_CURROW
244 && fScope != SQL_SCOPE_TRANSACTION
245 && fScope != SQL_SCOPE_SESSION)
246 {
247 sqlstat = en_S1098;
248 break;
249 }
250
251 if (fNullable != SQL_NO_NULLS && fNullable != SQL_NULLABLE)
252 {
253 sqlstat = en_S1099;
254 break;
255 }
256
257 retcode = _iodbcdm_cata_state_ok (hstmt, en_SpecialColumns);
258
259 if (retcode != SQL_SUCCESS)
260 {
261 return SQL_ERROR;
262 }
263
264 hproc = _iodbcdm_getproc (pstmt->hdbc, en_SpecialColumns);
265
266 if (hproc == SQL_NULL_HPROC)
267 {
268 sqlstat = en_IM001;
269 break;
270 }
271
272 sqlstat = en_00000;
273 if (1) /* turn off solaris warning message */
274 break;
275 }
276
277 if (sqlstat != en_00000)
278 {
279 PUSHSQLERR (pstmt->herr, sqlstat);
280
281 return SQL_ERROR;
282 }
283
284 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_SpecialColumns, (
285 pstmt->dhstmt,
286 fColType,
287 szTableQualifier,
288 cbTableQualifier,
289 szTableOwner,
290 cbTableOwner,
291 szTableName,
292 cbTableName,
293 fScope,
294 fNullable))
295
296 return _iodbcdm_cata_state_tr (hstmt, en_SpecialColumns, retcode);
1a6944fd
RR
297}
298
cd5bf2a6
RR
299
300RETCODE SQL_API
301SQLStatistics (
302 HSTMT hstmt,
303 UCHAR FAR * szTableQualifier,
304 SWORD cbTableQualifier,
305 UCHAR FAR * szTableOwner,
306 SWORD cbTableOwner,
307 UCHAR FAR * szTableName,
308 SWORD cbTableName,
309 UWORD fUnique,
310 UWORD fAccuracy)
1a6944fd 311{
cd5bf2a6
RR
312 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
313 HPROC hproc = SQL_NULL_HPROC;
314 RETCODE retcode;
315 int sqlstat = en_00000;
316
317 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
318 {
319 return SQL_INVALID_HANDLE;
320 }
321
322 for (;;)
323 {
324 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
325 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
326 || (cbTableName < 0 && cbTableName != SQL_NTS))
327 {
328 sqlstat = en_S1090;
329 break;
330 }
331
332 if (fUnique != SQL_INDEX_UNIQUE && fUnique != SQL_INDEX_ALL)
333 {
334 sqlstat = en_S1100;
335 break;
336 }
337
338 if (fAccuracy != SQL_ENSURE && fAccuracy != SQL_QUICK)
339 {
340 sqlstat = en_S1101;
341 break;
342 }
343
344 retcode = _iodbcdm_cata_state_ok (hstmt, en_Statistics);
345
346 if (retcode != SQL_SUCCESS)
347 {
348 return SQL_ERROR;
349 }
350
351 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Statistics);
352
353 if (hproc == SQL_NULL_HPROC)
354 {
355 sqlstat = en_IM001;
356 break;
357 }
358
359 sqlstat = en_00000;
360
361 if (1) /* turn off solaris warning message */
362 break;
363 }
364
365 if (sqlstat != en_00000)
366 {
367 PUSHSQLERR (pstmt->herr, sqlstat);
368
369 return SQL_ERROR;
370 }
371
372 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Statistics, (
373 pstmt->dhstmt,
374 szTableQualifier,
375 cbTableQualifier,
376 szTableOwner,
377 cbTableOwner,
378 szTableName,
379 cbTableName,
380 fUnique,
381 fAccuracy))
382
383 return _iodbcdm_cata_state_tr (hstmt, en_Statistics, retcode);
1a6944fd
RR
384}
385
cd5bf2a6
RR
386
387RETCODE SQL_API
388SQLTables (
389 HSTMT hstmt,
390 UCHAR FAR * szTableQualifier,
391 SWORD cbTableQualifier,
392 UCHAR FAR * szTableOwner,
393 SWORD cbTableOwner,
394 UCHAR FAR * szTableName,
395 SWORD cbTableName,
396 UCHAR FAR * szTableType,
397 SWORD cbTableType)
1a6944fd 398{
cd5bf2a6
RR
399 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
400 HPROC hproc = SQL_NULL_HPROC;
401 RETCODE retcode;
402 int sqlstat = en_00000;
403
404 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
405 {
406 return SQL_INVALID_HANDLE;
407 }
408
409 for (;;)
410 {
411 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
412 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
413 || (cbTableName < 0 && cbTableName != SQL_NTS)
414 || (cbTableType < 0 && cbTableType != SQL_NTS))
415 {
416 sqlstat = en_S1090;
417 break;
418 }
419
420 retcode = _iodbcdm_cata_state_ok (hstmt, en_Tables);
421
422 if (retcode != SQL_SUCCESS)
423 {
424 return SQL_ERROR;
425 }
426
427 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Tables);
428
429 if (hproc == SQL_NULL_HPROC)
430 {
431 sqlstat = en_IM001;
432 break;
433 }
434
435 sqlstat = en_00000;
436
437 if (1) /* turn off solaris warning message */
438 break;
439 }
440
441 if (sqlstat != en_00000)
442 {
443 PUSHSQLERR (pstmt->herr, sqlstat);
444
445 return SQL_ERROR;
446 }
447
448 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Tables, (
449 pstmt->dhstmt,
450 szTableQualifier,
451 cbTableQualifier,
452 szTableOwner,
453 cbTableOwner,
454 szTableName,
455 cbTableName,
456 szTableType,
457 cbTableType))
458
459 return _iodbcdm_cata_state_tr (hstmt, en_Tables, retcode);
1a6944fd
RR
460}
461
cd5bf2a6
RR
462
463RETCODE SQL_API
464SQLColumnPrivileges (
465 HSTMT hstmt,
466 UCHAR FAR * szTableQualifier,
467 SWORD cbTableQualifier,
468 UCHAR FAR * szTableOwner,
469 SWORD cbTableOwner,
470 UCHAR FAR * szTableName,
471 SWORD cbTableName,
472 UCHAR FAR * szColumnName,
473 SWORD cbColumnName)
1a6944fd 474{
cd5bf2a6
RR
475 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
476 HPROC hproc = SQL_NULL_HPROC;
477 RETCODE retcode;
478 int sqlstat = en_00000;
479
480 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
481 {
482 return SQL_INVALID_HANDLE;
483 }
484
485 for (;;)
486 {
487 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
488 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
489 || (cbTableName < 0 && cbTableName != SQL_NTS)
490 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
491 {
492 sqlstat = en_S1090;
493 break;
494 }
495
496 retcode = _iodbcdm_cata_state_ok (hstmt, en_ColumnPrivileges);
497
498 if (retcode != SQL_SUCCESS)
499 {
500 return SQL_ERROR;
501 }
502
503 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ColumnPrivileges);
504
505 if (hproc == SQL_NULL_HPROC)
506 {
507 sqlstat = en_IM001;
508 break;
509 }
510
511 sqlstat = en_00000;
512
513 if (1) /* turn off solaris warning message */
514 break;
515 }
516
517 if (sqlstat != en_00000)
518 {
519 PUSHSQLERR (pstmt->herr, sqlstat);
520
521 return SQL_ERROR;
522 }
523
524 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ColumnPrivileges, (
525 pstmt->dhstmt,
526 szTableQualifier,
527 cbTableQualifier,
528 szTableOwner,
529 cbTableOwner,
530 szTableName,
531 cbTableName,
532 szColumnName,
533 cbColumnName))
534
535 return _iodbcdm_cata_state_tr (hstmt, en_ColumnPrivileges, retcode);
1a6944fd
RR
536}
537
cd5bf2a6
RR
538
539RETCODE SQL_API
540SQLColumns (
541 HSTMT hstmt,
542 UCHAR FAR * szTableQualifier,
543 SWORD cbTableQualifier,
544 UCHAR FAR * szTableOwner,
545 SWORD cbTableOwner,
546 UCHAR FAR * szTableName,
547 SWORD cbTableName,
548 UCHAR FAR * szColumnName,
549 SWORD cbColumnName)
1a6944fd 550{
cd5bf2a6
RR
551 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
552 HPROC hproc = SQL_NULL_HPROC;
553 RETCODE retcode;
554 int sqlstat = en_00000;
555
556 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
557 {
558 return SQL_INVALID_HANDLE;
559 }
560
561 for (;;)
562 {
563 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
564 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
565 || (cbTableName < 0 && cbTableName != SQL_NTS)
566 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
567 {
568 sqlstat = en_S1090;
569 break;
570 }
571
572 retcode = _iodbcdm_cata_state_ok (hstmt, en_Columns);
573
574 if (retcode != SQL_SUCCESS)
575 {
576 return SQL_ERROR;
577 }
578
579 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Columns);
580
581 if (hproc == SQL_NULL_HPROC)
582 {
583 sqlstat = en_IM001;
584 break;
585 }
586
587 sqlstat = en_00000;
588
589 if (1) /* turn off solaris warning message */
590 break;
591 }
592
593 if (sqlstat != en_00000)
594 {
595 PUSHSQLERR (pstmt->herr, sqlstat);
596
597 return SQL_ERROR;
598 }
599
600 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Columns, (
601 pstmt->dhstmt,
602 szTableQualifier,
603 cbTableQualifier,
604 szTableOwner,
605 cbTableOwner,
606 szTableName,
607 cbTableName,
608 szColumnName,
609 cbColumnName))
610
611 return _iodbcdm_cata_state_tr (hstmt, en_Columns, retcode);
1a6944fd
RR
612}
613
cd5bf2a6
RR
614
615RETCODE SQL_API
616SQLForeignKeys (
617 HSTMT hstmt,
618 UCHAR FAR * szPkTableQualifier,
619 SWORD cbPkTableQualifier,
620 UCHAR FAR * szPkTableOwner,
621 SWORD cbPkTableOwner,
622 UCHAR FAR * szPkTableName,
623 SWORD cbPkTableName,
624 UCHAR FAR * szFkTableQualifier,
625 SWORD cbFkTableQualifier,
626 UCHAR FAR * szFkTableOwner,
627 SWORD cbFkTableOwner,
628 UCHAR FAR * szFkTableName,
629 SWORD cbFkTableName)
1a6944fd 630{
cd5bf2a6
RR
631 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
632 HPROC hproc = SQL_NULL_HPROC;
633 RETCODE retcode;
634 int sqlstat = en_00000;
635
636 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
637 {
638 return SQL_INVALID_HANDLE;
639 }
640
641 for (;;)
642 {
643 if ((cbPkTableQualifier < 0 && cbPkTableQualifier != SQL_NTS)
644 || (cbPkTableOwner < 0 && cbPkTableOwner != SQL_NTS)
645 || (cbPkTableName < 0 && cbPkTableName != SQL_NTS)
646 || (cbFkTableQualifier < 0 && cbFkTableQualifier != SQL_NTS)
647 || (cbFkTableOwner < 0 && cbFkTableOwner != SQL_NTS)
648 || (cbFkTableName < 0 && cbFkTableName != SQL_NTS))
649 {
650 sqlstat = en_S1090;
651 break;
652 }
653
654 retcode = _iodbcdm_cata_state_ok (hstmt, en_ForeignKeys);
655
656 if (retcode != SQL_SUCCESS)
657 {
658 return SQL_ERROR;
659 }
660
661 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ForeignKeys);
662
663 if (hproc == SQL_NULL_HPROC)
664 {
665 sqlstat = en_IM001;
666 break;
667 }
668
669 sqlstat = en_00000;
670
671 if (1) /* turn off solaris warning message */
672 break;
673 }
674
675 if (sqlstat != en_00000)
676 {
677 PUSHSQLERR (pstmt->herr, sqlstat);
678
679 return SQL_ERROR;
680 }
681
682 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ForeignKeys, (
683 pstmt->dhstmt,
684 szPkTableQualifier,
685 cbPkTableQualifier,
686 szPkTableOwner,
687 cbPkTableOwner,
688 szPkTableName,
689 cbPkTableName,
690 szFkTableQualifier,
691 cbFkTableQualifier,
692 szFkTableOwner,
693 cbFkTableOwner,
694 szFkTableName,
695 cbFkTableName))
696
697 return _iodbcdm_cata_state_tr (hstmt, en_ForeignKeys, retcode);
1a6944fd
RR
698}
699
cd5bf2a6
RR
700
701RETCODE SQL_API
702SQLPrimaryKeys (
703 HSTMT hstmt,
704 UCHAR FAR * szTableQualifier,
705 SWORD cbTableQualifier,
706 UCHAR FAR * szTableOwner,
707 SWORD cbTableOwner,
708 UCHAR FAR * szTableName,
709 SWORD cbTableName)
1a6944fd 710{
cd5bf2a6
RR
711 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
712 HPROC hproc = SQL_NULL_HPROC;
713 RETCODE retcode;
714 int sqlstat = en_00000;
715
716 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
717 {
718 return SQL_INVALID_HANDLE;
719 }
720
721 for (;;)
722 {
723 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
724 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
725 || (cbTableName < 0 && cbTableName != SQL_NTS))
726 {
727 sqlstat = en_S1090;
728 break;
729 }
730
731 retcode = _iodbcdm_cata_state_ok (hstmt, en_PrimaryKeys);
732
733 if (retcode != SQL_SUCCESS)
734 {
735 return SQL_ERROR;
736 }
737
738 hproc = _iodbcdm_getproc (pstmt->hdbc, en_PrimaryKeys);
739
740 if (hproc == SQL_NULL_HPROC)
741 {
742 sqlstat = en_IM001;
743 break;
744 }
745
746 sqlstat = en_00000;
747
748 if (1) /* turn off solaris warning message */
749 break;
750 }
751
752 if (sqlstat != en_00000)
753 {
754 PUSHSQLERR (pstmt->herr, sqlstat);
755
756 return SQL_ERROR;
757 }
758
759 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_PrimaryKeys, (
760 pstmt->dhstmt,
761 szTableQualifier,
762 cbTableQualifier,
763 szTableOwner,
764 cbTableOwner,
765 szTableName,
766 cbTableName))
767
768 return _iodbcdm_cata_state_tr (hstmt, en_PrimaryKeys, retcode);
1a6944fd
RR
769}
770
cd5bf2a6
RR
771
772RETCODE SQL_API
773SQLProcedureColumns (
774 HSTMT hstmt,
775 UCHAR FAR * szProcQualifier,
776 SWORD cbProcQualifier,
777 UCHAR FAR * szProcOwner,
778 SWORD cbProcOwner,
779 UCHAR FAR * szProcName,
780 SWORD cbProcName,
781 UCHAR FAR * szColumnName,
782 SWORD cbColumnName)
1a6944fd 783{
cd5bf2a6
RR
784 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
785 HPROC hproc = SQL_NULL_HPROC;
786 RETCODE retcode;
787 int sqlstat = en_00000;
788
789 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
790 {
791 return SQL_INVALID_HANDLE;
792 }
793
794 for (;;)
795 {
796 if ((cbProcQualifier < 0 && cbProcQualifier != SQL_NTS)
797 || (cbProcOwner < 0 && cbProcOwner != SQL_NTS)
798 || (cbProcName < 0 && cbProcName != SQL_NTS)
799 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
800 {
801 sqlstat = en_S1090;
802 break;
803 }
804
805 retcode = _iodbcdm_cata_state_ok (hstmt, en_ProcedureColumns);
806
807 if (retcode != SQL_SUCCESS)
808 {
809 return SQL_ERROR;
810 }
811
812 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ProcedureColumns);
813
814 if (hproc == SQL_NULL_HPROC)
815 {
816 sqlstat = en_IM001;
817 break;
818 }
819
820 sqlstat = en_00000;
821
822 if (1) /* turn off solaris warning message */
823 break;
824 }
825
826 if (sqlstat != en_00000)
827 {
828 PUSHSQLERR (pstmt->herr, sqlstat);
829
830 return SQL_ERROR;
831 }
832
833 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ProcedureColumns, (
834 pstmt->dhstmt,
835 szProcQualifier,
836 cbProcQualifier,
837 szProcOwner,
838 cbProcOwner,
839 szProcName,
840 cbProcName,
841 szColumnName,
842 cbColumnName))
843
844 return _iodbcdm_cata_state_tr (hstmt, en_ProcedureColumns, retcode);
1a6944fd
RR
845}
846
cd5bf2a6
RR
847
848RETCODE SQL_API
849SQLProcedures (
850 HSTMT hstmt,
851 UCHAR FAR * szProcQualifier,
852 SWORD cbProcQualifier,
853 UCHAR FAR * szProcOwner,
854 SWORD cbProcOwner,
855 UCHAR FAR * szProcName,
856 SWORD cbProcName)
1a6944fd 857{
cd5bf2a6
RR
858 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
859 HPROC hproc = SQL_NULL_HPROC;
860 RETCODE retcode;
861 int sqlstat = en_00000;
862
863 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
864 {
865 return SQL_INVALID_HANDLE;
866 }
867
868 for (;;)
869 {
870 if ((cbProcQualifier < 0 && cbProcQualifier != SQL_NTS)
871 || (cbProcOwner < 0 && cbProcOwner != SQL_NTS)
872 || (cbProcName < 0 && cbProcName != SQL_NTS))
873 {
874 sqlstat = en_S1090;
875 break;
876 }
877
878 retcode = _iodbcdm_cata_state_ok (hstmt, en_Procedures);
879
880 if (retcode != SQL_SUCCESS)
881 {
882 return SQL_ERROR;
883 }
884
885 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Procedures);
886
887 if (hproc == SQL_NULL_HPROC)
888 {
889 sqlstat = en_IM001;
890 break;
891 }
892
893 sqlstat = en_00000;
894
895 if (1) /* turn off solaris warning message */
896 break;
897 }
898
899 if (sqlstat != en_00000)
900 {
901 PUSHSQLERR (pstmt->herr, sqlstat);
902
903 return SQL_ERROR;
904 }
905
906 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Procedures, (
907 pstmt->dhstmt,
908 szProcQualifier,
909 cbProcQualifier,
910 szProcOwner,
911 cbProcOwner,
912 szProcName,
913 cbProcName))
914
915 return _iodbcdm_cata_state_tr (hstmt, en_Procedures, retcode);
1a6944fd
RR
916}
917
cd5bf2a6
RR
918
919RETCODE SQL_API
920SQLTablePrivileges (
921 HSTMT hstmt,
922 UCHAR FAR * szTableQualifier,
923 SWORD cbTableQualifier,
924 UCHAR FAR * szTableOwner,
925 SWORD cbTableOwner,
926 UCHAR FAR * szTableName,
927 SWORD cbTableName)
1a6944fd
RR
928{
929
cd5bf2a6
RR
930 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
931 HPROC hproc = SQL_NULL_HPROC;
932 RETCODE retcode;
933 int sqlstat = en_00000;
934
935 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
936 {
937 return SQL_INVALID_HANDLE;
938 }
939
940 for (;;)
941 {
942 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
943 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
944 || (cbTableName < 0 && cbTableName != SQL_NTS))
945 {
946 sqlstat = en_S1090;
947 break;
948 }
949
950 retcode = _iodbcdm_cata_state_ok (hstmt, en_TablePrivileges);
951
952 if (retcode != SQL_SUCCESS)
953 {
954 return SQL_ERROR;
955 }
956
957 hproc = _iodbcdm_getproc (pstmt->hdbc, en_TablePrivileges);
958
959 if (hproc == SQL_NULL_HPROC)
960 {
961 sqlstat = en_IM001;
962 break;
963 }
964
965 sqlstat = en_00000;
966
967 if (1) /* turn off solaris warning message */
968 break;
969 }
970
971 if (sqlstat != en_00000)
972 {
973 PUSHSQLERR (pstmt->herr, sqlstat);
974
975 return SQL_ERROR;
976 }
977
978 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_TablePrivileges,
979 (pstmt->dhstmt, szTableQualifier, cbTableQualifier, szTableOwner,
980 cbTableOwner, szTableName, cbTableName))
981
982 return _iodbcdm_cata_state_tr (hstmt, en_TablePrivileges, retcode);
1a6944fd 983}