]>
git.saurik.com Git - wxWidgets.git/blob - src/iodbc/catalog.c
8 * The iODBC driver manager.
10 * Copyright (C) 1995 by Ke Jin <kejin@empress.com>
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.
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.
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.
42 _iodbcdm_cata_state_ok (
45 /* check state for executing catalog functions */
47 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
48 int sqlstat
= en_00000
;
50 if (pstmt
->asyn_on
== en_NullProc
)
54 case en_stmt_needdata
:
61 case en_stmt_xfetched
:
69 else if (pstmt
->asyn_on
!= fidx
)
74 if (sqlstat
!= en_00000
)
76 PUSHSQLERR (pstmt
->herr
, sqlstat
);
86 _iodbcdm_cata_state_tr (
90 /* state transition for catalog function */
92 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
95 pdbc
= (DBC_t FAR
*) (pstmt
->hdbc
);
97 if (pstmt
->asyn_on
== fidx
)
102 case SQL_SUCCESS_WITH_INFO
:
104 pstmt
->asyn_on
= en_NullProc
;
107 case SQL_STILL_EXECUTING
:
113 if (pstmt
->state
<= en_stmt_executed
)
118 case SQL_SUCCESS_WITH_INFO
:
119 pstmt
->state
= en_stmt_cursoropen
;
123 pstmt
->state
= en_stmt_allocated
;
124 pstmt
->prep_state
= 0;
127 case SQL_STILL_EXECUTING
:
128 pstmt
->asyn_on
= fidx
;
145 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
146 HPROC hproc
= SQL_NULL_HPROC
;
147 int sqlstat
= en_00000
;
150 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
152 return SQL_INVALID_HANDLE
;
157 if (fSqlType
> SQL_TYPE_MAX
)
163 /* Note: SQL_TYPE_DRIVER_START is a negative number So, we use ">" */
164 if (fSqlType
< SQL_TYPE_MIN
&& fSqlType
> SQL_TYPE_DRIVER_START
)
170 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_GetTypeInfo
);
172 if (retcode
!= SQL_SUCCESS
)
177 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_GetTypeInfo
);
179 if (hproc
== SQL_NULL_HPROC
)
186 if (1) /* turn off solaris warning message */
190 if (sqlstat
!= en_00000
)
192 PUSHSQLERR (pstmt
->herr
, sqlstat
);
197 CALL_DRIVER ( pstmt
->hdbc
, retcode
, hproc
, en_GetTypeInfo
,
198 (pstmt
->dhstmt
, fSqlType
))
200 return _iodbcdm_cata_state_tr (hstmt
, en_GetTypeInfo
, retcode
);
208 UCHAR FAR
* szTableQualifier
,
209 SWORD cbTableQualifier
,
210 UCHAR FAR
* szTableOwner
,
212 UCHAR FAR
* szTableName
,
217 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
218 HPROC hproc
= SQL_NULL_HPROC
;
220 int sqlstat
= en_00000
;
222 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
224 return SQL_INVALID_HANDLE
;
229 if ((cbTableQualifier
< 0 && cbTableQualifier
!= SQL_NTS
)
230 || (cbTableOwner
< 0 && cbTableOwner
!= SQL_NTS
)
231 || (cbTableName
< 0 && cbTableName
!= SQL_NTS
))
237 if (fColType
!= SQL_BEST_ROWID
&& fColType
!= SQL_ROWVER
)
243 if (fScope
!= SQL_SCOPE_CURROW
244 && fScope
!= SQL_SCOPE_TRANSACTION
245 && fScope
!= SQL_SCOPE_SESSION
)
251 if (fNullable
!= SQL_NO_NULLS
&& fNullable
!= SQL_NULLABLE
)
257 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_SpecialColumns
);
259 if (retcode
!= SQL_SUCCESS
)
264 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_SpecialColumns
);
266 if (hproc
== SQL_NULL_HPROC
)
273 if (1) /* turn off solaris warning message */
277 if (sqlstat
!= en_00000
)
279 PUSHSQLERR (pstmt
->herr
, sqlstat
);
284 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_SpecialColumns
, (
296 return _iodbcdm_cata_state_tr (hstmt
, en_SpecialColumns
, retcode
);
303 UCHAR FAR
* szTableQualifier
,
304 SWORD cbTableQualifier
,
305 UCHAR FAR
* szTableOwner
,
307 UCHAR FAR
* szTableName
,
312 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
313 HPROC hproc
= SQL_NULL_HPROC
;
315 int sqlstat
= en_00000
;
317 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
319 return SQL_INVALID_HANDLE
;
324 if ((cbTableQualifier
< 0 && cbTableQualifier
!= SQL_NTS
)
325 || (cbTableOwner
< 0 && cbTableOwner
!= SQL_NTS
)
326 || (cbTableName
< 0 && cbTableName
!= SQL_NTS
))
332 if (fUnique
!= SQL_INDEX_UNIQUE
&& fUnique
!= SQL_INDEX_ALL
)
338 if (fAccuracy
!= SQL_ENSURE
&& fAccuracy
!= SQL_QUICK
)
344 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_Statistics
);
346 if (retcode
!= SQL_SUCCESS
)
351 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_Statistics
);
353 if (hproc
== SQL_NULL_HPROC
)
361 if (1) /* turn off solaris warning message */
365 if (sqlstat
!= en_00000
)
367 PUSHSQLERR (pstmt
->herr
, sqlstat
);
372 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_Statistics
, (
383 return _iodbcdm_cata_state_tr (hstmt
, en_Statistics
, retcode
);
390 UCHAR FAR
* szTableQualifier
,
391 SWORD cbTableQualifier
,
392 UCHAR FAR
* szTableOwner
,
394 UCHAR FAR
* szTableName
,
396 UCHAR FAR
* szTableType
,
399 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
400 HPROC hproc
= SQL_NULL_HPROC
;
402 int sqlstat
= en_00000
;
404 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
406 return SQL_INVALID_HANDLE
;
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
))
420 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_Tables
);
422 if (retcode
!= SQL_SUCCESS
)
427 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_Tables
);
429 if (hproc
== SQL_NULL_HPROC
)
437 if (1) /* turn off solaris warning message */
441 if (sqlstat
!= en_00000
)
443 PUSHSQLERR (pstmt
->herr
, sqlstat
);
448 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_Tables
, (
459 return _iodbcdm_cata_state_tr (hstmt
, en_Tables
, retcode
);
464 SQLColumnPrivileges (
466 UCHAR FAR
* szTableQualifier
,
467 SWORD cbTableQualifier
,
468 UCHAR FAR
* szTableOwner
,
470 UCHAR FAR
* szTableName
,
472 UCHAR FAR
* szColumnName
,
475 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
476 HPROC hproc
= SQL_NULL_HPROC
;
478 int sqlstat
= en_00000
;
480 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
482 return SQL_INVALID_HANDLE
;
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
))
496 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_ColumnPrivileges
);
498 if (retcode
!= SQL_SUCCESS
)
503 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_ColumnPrivileges
);
505 if (hproc
== SQL_NULL_HPROC
)
513 if (1) /* turn off solaris warning message */
517 if (sqlstat
!= en_00000
)
519 PUSHSQLERR (pstmt
->herr
, sqlstat
);
524 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_ColumnPrivileges
, (
535 return _iodbcdm_cata_state_tr (hstmt
, en_ColumnPrivileges
, retcode
);
542 UCHAR FAR
* szTableQualifier
,
543 SWORD cbTableQualifier
,
544 UCHAR FAR
* szTableOwner
,
546 UCHAR FAR
* szTableName
,
548 UCHAR FAR
* szColumnName
,
551 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
552 HPROC hproc
= SQL_NULL_HPROC
;
554 int sqlstat
= en_00000
;
556 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
558 return SQL_INVALID_HANDLE
;
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
))
572 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_Columns
);
574 if (retcode
!= SQL_SUCCESS
)
579 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_Columns
);
581 if (hproc
== SQL_NULL_HPROC
)
589 if (1) /* turn off solaris warning message */
593 if (sqlstat
!= en_00000
)
595 PUSHSQLERR (pstmt
->herr
, sqlstat
);
600 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_Columns
, (
611 return _iodbcdm_cata_state_tr (hstmt
, en_Columns
, retcode
);
618 UCHAR FAR
* szPkTableQualifier
,
619 SWORD cbPkTableQualifier
,
620 UCHAR FAR
* szPkTableOwner
,
621 SWORD cbPkTableOwner
,
622 UCHAR FAR
* szPkTableName
,
624 UCHAR FAR
* szFkTableQualifier
,
625 SWORD cbFkTableQualifier
,
626 UCHAR FAR
* szFkTableOwner
,
627 SWORD cbFkTableOwner
,
628 UCHAR FAR
* szFkTableName
,
631 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
632 HPROC hproc
= SQL_NULL_HPROC
;
634 int sqlstat
= en_00000
;
636 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
638 return SQL_INVALID_HANDLE
;
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
))
654 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_ForeignKeys
);
656 if (retcode
!= SQL_SUCCESS
)
661 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_ForeignKeys
);
663 if (hproc
== SQL_NULL_HPROC
)
671 if (1) /* turn off solaris warning message */
675 if (sqlstat
!= en_00000
)
677 PUSHSQLERR (pstmt
->herr
, sqlstat
);
682 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_ForeignKeys
, (
697 return _iodbcdm_cata_state_tr (hstmt
, en_ForeignKeys
, retcode
);
704 UCHAR FAR
* szTableQualifier
,
705 SWORD cbTableQualifier
,
706 UCHAR FAR
* szTableOwner
,
708 UCHAR FAR
* szTableName
,
711 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
712 HPROC hproc
= SQL_NULL_HPROC
;
714 int sqlstat
= en_00000
;
716 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
718 return SQL_INVALID_HANDLE
;
723 if ((cbTableQualifier
< 0 && cbTableQualifier
!= SQL_NTS
)
724 || (cbTableOwner
< 0 && cbTableOwner
!= SQL_NTS
)
725 || (cbTableName
< 0 && cbTableName
!= SQL_NTS
))
731 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_PrimaryKeys
);
733 if (retcode
!= SQL_SUCCESS
)
738 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_PrimaryKeys
);
740 if (hproc
== SQL_NULL_HPROC
)
748 if (1) /* turn off solaris warning message */
752 if (sqlstat
!= en_00000
)
754 PUSHSQLERR (pstmt
->herr
, sqlstat
);
759 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_PrimaryKeys
, (
768 return _iodbcdm_cata_state_tr (hstmt
, en_PrimaryKeys
, retcode
);
773 SQLProcedureColumns (
775 UCHAR FAR
* szProcQualifier
,
776 SWORD cbProcQualifier
,
777 UCHAR FAR
* szProcOwner
,
779 UCHAR FAR
* szProcName
,
781 UCHAR FAR
* szColumnName
,
784 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
785 HPROC hproc
= SQL_NULL_HPROC
;
787 int sqlstat
= en_00000
;
789 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
791 return SQL_INVALID_HANDLE
;
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
))
805 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_ProcedureColumns
);
807 if (retcode
!= SQL_SUCCESS
)
812 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_ProcedureColumns
);
814 if (hproc
== SQL_NULL_HPROC
)
822 if (1) /* turn off solaris warning message */
826 if (sqlstat
!= en_00000
)
828 PUSHSQLERR (pstmt
->herr
, sqlstat
);
833 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_ProcedureColumns
, (
844 return _iodbcdm_cata_state_tr (hstmt
, en_ProcedureColumns
, retcode
);
851 UCHAR FAR
* szProcQualifier
,
852 SWORD cbProcQualifier
,
853 UCHAR FAR
* szProcOwner
,
855 UCHAR FAR
* szProcName
,
858 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
859 HPROC hproc
= SQL_NULL_HPROC
;
861 int sqlstat
= en_00000
;
863 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
865 return SQL_INVALID_HANDLE
;
870 if ((cbProcQualifier
< 0 && cbProcQualifier
!= SQL_NTS
)
871 || (cbProcOwner
< 0 && cbProcOwner
!= SQL_NTS
)
872 || (cbProcName
< 0 && cbProcName
!= SQL_NTS
))
878 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_Procedures
);
880 if (retcode
!= SQL_SUCCESS
)
885 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_Procedures
);
887 if (hproc
== SQL_NULL_HPROC
)
895 if (1) /* turn off solaris warning message */
899 if (sqlstat
!= en_00000
)
901 PUSHSQLERR (pstmt
->herr
, sqlstat
);
906 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_Procedures
, (
915 return _iodbcdm_cata_state_tr (hstmt
, en_Procedures
, retcode
);
922 UCHAR FAR
* szTableQualifier
,
923 SWORD cbTableQualifier
,
924 UCHAR FAR
* szTableOwner
,
926 UCHAR FAR
* szTableName
,
930 STMT_t FAR
*pstmt
= (STMT_t FAR
*) hstmt
;
931 HPROC hproc
= SQL_NULL_HPROC
;
933 int sqlstat
= en_00000
;
935 if (hstmt
== SQL_NULL_HSTMT
|| pstmt
->hdbc
== SQL_NULL_HDBC
)
937 return SQL_INVALID_HANDLE
;
942 if ((cbTableQualifier
< 0 && cbTableQualifier
!= SQL_NTS
)
943 || (cbTableOwner
< 0 && cbTableOwner
!= SQL_NTS
)
944 || (cbTableName
< 0 && cbTableName
!= SQL_NTS
))
950 retcode
= _iodbcdm_cata_state_ok (hstmt
, en_TablePrivileges
);
952 if (retcode
!= SQL_SUCCESS
)
957 hproc
= _iodbcdm_getproc (pstmt
->hdbc
, en_TablePrivileges
);
959 if (hproc
== SQL_NULL_HPROC
)
967 if (1) /* turn off solaris warning message */
971 if (sqlstat
!= en_00000
)
973 PUSHSQLERR (pstmt
->herr
, sqlstat
);
978 CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_TablePrivileges
,
979 (pstmt
->dhstmt
, szTableQualifier
, cbTableQualifier
, szTableOwner
,
980 cbTableOwner
, szTableName
, cbTableName
))
982 return _iodbcdm_cata_state_tr (hstmt
, en_TablePrivileges
, retcode
);