2 * Description: This module contains routines related to ODBC 3.0
9 #include "connection.h"
10 #include "pgapifunc.h"
13 PGAPI_GetInfo30(HDBC hdbc
, SQLUSMALLINT fInfoType
, PTR rgbInfoValue
,
14 SQLSMALLINT cbInfoValueMax
,
15 SQLSMALLINT FAR
* pcbInfoValue
)
17 CSTR func
= "PGAPI_GetInfo30";
18 ConnectionClass
*conn
= (ConnectionClass
*) hdbc
;
19 ConnInfo
*ci
= &(conn
->connInfo
);
27 case SQL_DYNAMIC_CURSOR_ATTRIBUTES1
:
31 case SQL_DYNAMIC_CURSOR_ATTRIBUTES2
:
36 case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1
:
38 value
= SQL_CA1_NEXT
; /* others aren't allowed in ODBC spec */
40 case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2
:
42 value
= SQL_CA2_READ_ONLY_CONCURRENCY
;
43 value
|= SQL_CA2_CRC_EXACT
;
45 case SQL_KEYSET_CURSOR_ATTRIBUTES1
:
47 value
= SQL_CA1_NEXT
| SQL_CA1_ABSOLUTE
48 | SQL_CA1_RELATIVE
| SQL_CA1_BOOKMARK
49 | SQL_CA1_LOCK_NO_CHANGE
| SQL_CA1_POS_POSITION
50 | SQL_CA1_POS_REFRESH
;
51 if (0 != (ci
->updatable_cursors
& ALLOW_KEYSET_DRIVEN_CURSORS
))
52 value
|= (SQL_CA1_POS_UPDATE
| SQL_CA1_POS_DELETE
54 | SQL_CA1_BULK_UPDATE_BY_BOOKMARK
55 | SQL_CA1_BULK_DELETE_BY_BOOKMARK
56 | SQL_CA1_BULK_FETCH_BY_BOOKMARK
);
58 case SQL_KEYSET_CURSOR_ATTRIBUTES2
:
60 value
= SQL_CA2_READ_ONLY_CONCURRENCY
;
61 if (0 != (ci
->updatable_cursors
& ALLOW_KEYSET_DRIVEN_CURSORS
))
62 value
|= (SQL_CA2_OPT_ROWVER_CONCURRENCY
63 /*| SQL_CA2_CRC_APPROXIMATE */
65 if (0 != (ci
->updatable_cursors
& SENSE_SELF_OPERATIONS
))
66 value
|= (SQL_CA2_SENSITIVITY_DELETIONS
67 | SQL_CA2_SENSITIVITY_UPDATES
68 | SQL_CA2_SENSITIVITY_ADDITIONS
);
69 value
|= SQL_CA2_CRC_EXACT
;
72 case SQL_STATIC_CURSOR_ATTRIBUTES1
:
74 value
= SQL_CA1_NEXT
| SQL_CA1_ABSOLUTE
75 | SQL_CA1_RELATIVE
| SQL_CA1_BOOKMARK
76 | SQL_CA1_LOCK_NO_CHANGE
| SQL_CA1_POS_POSITION
77 | SQL_CA1_POS_REFRESH
;
78 if (0 != (ci
->updatable_cursors
& ALLOW_STATIC_CURSORS
))
79 value
|= (SQL_CA1_POS_UPDATE
| SQL_CA1_POS_DELETE
);
80 if (0 != (ci
->updatable_cursors
& ALLOW_BULK_OPERATIONS
))
81 value
|= (SQL_CA1_BULK_ADD
82 | SQL_CA1_BULK_UPDATE_BY_BOOKMARK
83 | SQL_CA1_BULK_DELETE_BY_BOOKMARK
84 | SQL_CA1_BULK_FETCH_BY_BOOKMARK
);
86 case SQL_STATIC_CURSOR_ATTRIBUTES2
:
88 value
= SQL_CA2_READ_ONLY_CONCURRENCY
;
89 if (0 != (ci
->updatable_cursors
& ALLOW_STATIC_CURSORS
))
90 value
|= (SQL_CA2_OPT_ROWVER_CONCURRENCY
);
91 if (0 != (ci
->updatable_cursors
& SENSE_SELF_OPERATIONS
))
92 value
|= (SQL_CA2_SENSITIVITY_DELETIONS
93 | SQL_CA2_SENSITIVITY_UPDATES
94 | SQL_CA2_SENSITIVITY_ADDITIONS
);
95 value
|= (SQL_CA2_CRC_EXACT
);
98 case SQL_ODBC_INTERFACE_CONFORMANCE
:
100 value
= SQL_OIC_CORE
;
102 case SQL_ACTIVE_ENVIRONMENTS
:
106 case SQL_AGGREGATE_FUNCTIONS
:
110 case SQL_ALTER_DOMAIN
:
118 case SQL_BATCH_ROW_COUNT
:
120 value
= SQL_BRC_EXPLICIT
;
122 case SQL_BATCH_SUPPORT
:
124 value
= SQL_BS_SELECT_EXPLICIT
| SQL_BS_ROW_COUNT_EXPLICIT
;
126 case SQL_CATALOG_NAME
:
133 case SQL_COLLATION_SEQ
:
137 case SQL_CREATE_ASSERTION
:
141 case SQL_CREATE_CHARACTER_SET
:
145 case SQL_CREATE_COLLATION
:
149 case SQL_CREATE_DOMAIN
:
153 case SQL_CREATE_SCHEMA
:
155 if (conn
->schema_support
)
156 value
= SQL_CS_CREATE_SCHEMA
| SQL_CS_AUTHORIZATION
;
160 case SQL_CREATE_TABLE
:
162 value
= SQL_CT_CREATE_TABLE
| SQL_CT_COLUMN_CONSTRAINT
163 | SQL_CT_COLUMN_DEFAULT
;
164 if (PG_VERSION_GE(conn
, 6.5))
165 value
|= SQL_CT_GLOBAL_TEMPORARY
;
166 if (PG_VERSION_GE(conn
, 7.0))
167 value
|= SQL_CT_TABLE_CONSTRAINT
168 | SQL_CT_CONSTRAINT_NAME_DEFINITION
169 | SQL_CT_CONSTRAINT_INITIALLY_DEFERRED
170 | SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE
171 | SQL_CT_CONSTRAINT_DEFERRABLE
;
173 case SQL_CREATE_TRANSLATION
:
177 case SQL_CREATE_VIEW
:
179 value
= SQL_CV_CREATE_VIEW
;
183 value
= SQL_DI_CREATE_INDEX
| SQL_DI_DROP_INDEX
;
185 case SQL_DESCRIBE_PARAMETER
:
189 case SQL_DROP_ASSERTION
:
193 case SQL_DROP_CHARACTER_SET
:
197 case SQL_DROP_COLLATION
:
201 case SQL_DROP_DOMAIN
:
205 case SQL_DROP_SCHEMA
:
207 if (conn
->schema_support
)
209 SQL_DS_DROP_SCHEMA
| SQL_DS_RESTRICT
| SQL_DS_CASCADE
;
215 value
= SQL_DT_DROP_TABLE
;
216 if (PG_VERSION_GT(conn
, 7.2)) /* hopefully */
217 value
|= (SQL_DT_RESTRICT
| SQL_DT_CASCADE
);
219 case SQL_DROP_TRANSLATION
:
225 value
= SQL_DV_DROP_VIEW
;
226 if (PG_VERSION_GT(conn
, 7.2)) /* hopefully */
227 value
|= (SQL_DV_RESTRICT
| SQL_DV_CASCADE
);
229 case SQL_INDEX_KEYWORDS
:
232 case SQL_INFO_SCHEMA_VIEWS
:
236 case SQL_INSERT_STATEMENT
:
239 SQL_IS_INSERT_LITERALS
| SQL_IS_INSERT_SEARCHED
|
242 case SQL_MAX_IDENTIFIER_LEN
:
245 if (PG_VERSION_GT(conn
, 7.2))
248 case SQL_MAX_ROW_SIZE_INCLUDES_LONG
:
252 case SQL_PARAM_ARRAY_ROW_COUNTS
:
254 value
= SQL_PARC_BATCH
;
256 case SQL_PARAM_ARRAY_SELECTS
:
258 value
= SQL_PAS_BATCH
;
260 case SQL_SQL_CONFORMANCE
:
262 value
= SQL_SC_SQL92_ENTRY
;
264 case SQL_SQL92_DATETIME_FUNCTIONS
:
267 SQL_SDF_CURRENT_DATE
| SQL_SDF_CURRENT_TIME
|
268 SQL_SDF_CURRENT_TIMESTAMP
;
270 case SQL_SQL92_FOREIGN_KEY_DELETE_RULE
:
273 SQL_SFKD_CASCADE
| SQL_SFKD_NO_ACTION
| SQL_SFKD_SET_DEFAULT
276 case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE
:
279 SQL_SFKU_CASCADE
| SQL_SFKU_NO_ACTION
| SQL_SFKU_SET_DEFAULT
282 case SQL_SQL92_GRANT
:
285 SQL_SG_DELETE_TABLE
| SQL_SG_INSERT_TABLE
|
286 SQL_SG_REFERENCES_TABLE
| SQL_SG_SELECT_TABLE
|
289 case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
:
291 value
= SQL_SNVF_BIT_LENGTH
| SQL_SNVF_CHAR_LENGTH
292 | SQL_SNVF_CHARACTER_LENGTH
| SQL_SNVF_EXTRACT
293 | SQL_SNVF_OCTET_LENGTH
| SQL_SNVF_POSITION
;
295 case SQL_SQL92_PREDICATES
:
297 value
= SQL_SP_BETWEEN
| SQL_SP_COMPARISON
298 | SQL_SP_EXISTS
| SQL_SP_IN
299 | SQL_SP_ISNOTNULL
| SQL_SP_ISNULL
300 | SQL_SP_LIKE
| SQL_SP_OVERLAPS
301 | SQL_SP_QUANTIFIED_COMPARISON
;
303 case SQL_SQL92_RELATIONAL_JOIN_OPERATORS
:
305 if (PG_VERSION_GE(conn
, 7.1))
306 value
= SQL_SRJO_CROSS_JOIN
| SQL_SRJO_EXCEPT_JOIN
307 | SQL_SRJO_FULL_OUTER_JOIN
| SQL_SRJO_INNER_JOIN
308 | SQL_SRJO_INTERSECT_JOIN
| SQL_SRJO_LEFT_OUTER_JOIN
309 | SQL_SRJO_NATURAL_JOIN
| SQL_SRJO_RIGHT_OUTER_JOIN
310 | SQL_SRJO_UNION_JOIN
;
312 case SQL_SQL92_REVOKE
:
315 SQL_SR_DELETE_TABLE
| SQL_SR_INSERT_TABLE
|
316 SQL_SR_REFERENCES_TABLE
| SQL_SR_SELECT_TABLE
|
319 case SQL_SQL92_ROW_VALUE_CONSTRUCTOR
:
321 value
= SQL_SRVC_VALUE_EXPRESSION
| SQL_SRVC_NULL
;
323 case SQL_SQL92_STRING_FUNCTIONS
:
325 value
= SQL_SSF_CONVERT
| SQL_SSF_LOWER
326 | SQL_SSF_UPPER
| SQL_SSF_SUBSTRING
327 | SQL_SSF_TRANSLATE
| SQL_SSF_TRIM_BOTH
328 | SQL_SSF_TRIM_LEADING
| SQL_SSF_TRIM_TRAILING
;
330 case SQL_SQL92_VALUE_EXPRESSIONS
:
333 SQL_SVE_CASE
| SQL_SVE_CAST
| SQL_SVE_COALESCE
|
336 #ifdef SQL_DTC_TRANSACTION_COST
337 case SQL_DTC_TRANSACTION_COST
:
343 /* The followings aren't implemented yet */
344 case SQL_DATETIME_LITERALS
:
348 case SQL_DRIVER_HDESC
:
350 case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
:
352 case SQL_STANDARD_CLI_CONFORMANCE
:
354 case SQL_XOPEN_CLI_YEAR
:
357 /* unrecognized key */
358 CC_set_error(conn
, CONN_NOT_IMPLEMENTED_ERROR
,
359 "Unrecognized key passed to SQLGetInfo30.", func
);
362 result
= SQL_SUCCESS
;
363 mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func
,
364 p
? p
: "<NULL>", len
, value
, cbInfoValueMax
);
367 /* char/binary data */
372 #ifdef UNICODE_SUPPORT
373 if (CC_is_in_unicode_driver(conn
))
376 utf8_to_ucs2(p
, len
, (SQLWCHAR
*) rgbInfoValue
,
377 cbInfoValueMax
/ WCLEN
);
380 #endif /* UNICODE_SUPPORT */
381 strncpy_null((char *) rgbInfoValue
, p
,
382 (size_t) cbInfoValueMax
);
384 if (len
>= cbInfoValueMax
)
386 result
= SQL_SUCCESS_WITH_INFO
;
387 CC_set_error(conn
, CONN_TRUNCATED
,
388 "The buffer was too small for tthe InfoValue.",
392 #ifdef UNICODE_SUPPORT
393 else if (CC_is_in_unicode_driver(conn
))
395 #endif /* UNICODE_SUPPORT */
402 *((WORD
*) rgbInfoValue
) = (WORD
) value
;
404 *((DWORD
*) rgbInfoValue
) = (DWORD
) value
;
409 *pcbInfoValue
= (SQLSMALLINT
) len
;