Fixed odbc_sql_get_diag_recs
This commit is contained in:
parent
a62bf26d5b
commit
180850580c
|
@ -253,7 +253,7 @@ s48_value odbc_sql_data_sources(s48_value env_handle)
|
|||
SQLSMALLINT server_name_len;
|
||||
SQLCHAR driver_descr[ODBC_MAX_DRIVER_NAME_LEN];
|
||||
SQLSMALLINT driver_descr_len;
|
||||
s48_value result;
|
||||
s48_value result = S48_UNSPECIFIC;
|
||||
int first, more_items;
|
||||
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
|
@ -323,7 +323,7 @@ s48_value odbc_sql_drivers(s48_value env_handle)
|
|||
SQLSMALLINT driver_descr_len;
|
||||
SQLCHAR driver_attr[ODBC_MAX_DRIVER_NAME_LEN];
|
||||
SQLSMALLINT driver_attr_len;
|
||||
s48_value result;
|
||||
s48_value result = S48_UNSPECIFIC;
|
||||
int first, more_items;
|
||||
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
|
@ -2031,25 +2031,24 @@ s48_value odbc_sql_get_diag_recs(s48_value handle_type, s48_value handle)
|
|||
SQLCHAR sql_state[6];
|
||||
SQLINTEGER native_error;
|
||||
SQLCHAR message[ERROR_MSG_BUFFER_LEN];
|
||||
SQLSMALLINT i, message_len;
|
||||
SQLSMALLINT i, message_len, more_recs;
|
||||
SQLRETURN retval;
|
||||
s48_value res;
|
||||
s48_value res = S48_UNSPECIFIC;
|
||||
s48_value diag_rec = S48_UNSPECIFIC;
|
||||
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
S48_GC_PROTECT_1(res);
|
||||
S48_GC_PROTECT_2(res, diag_rec);
|
||||
|
||||
ht = (SQLSMALLINT) s48_extract_integer(handle_type);
|
||||
h = (SQLHANDLE) s48_extract_integer(handle);
|
||||
res = S48_NULL;
|
||||
|
||||
ODBC_DEBUG_PRINTF("odbc_sql_get_diag_recs");
|
||||
ODBC_DEBUG_PRINTF("odbc_sql_get_diag_recs\n");
|
||||
|
||||
i = 1;
|
||||
while (1) {
|
||||
|
||||
s48_value diag_rec = s48_make_record(odbc_diag_record_type);
|
||||
S48_GC_PROTECT_1(diag_rec);
|
||||
i = more_recs = 1;
|
||||
while (more_recs) {
|
||||
|
||||
diag_rec = s48_make_record(odbc_diag_record_type);
|
||||
retval = SQLGetDiagRec(ht, h, i,
|
||||
sql_state, &native_error,
|
||||
message, sizeof(message), &message_len);
|
||||
|
@ -2058,14 +2057,15 @@ s48_value odbc_sql_get_diag_recs(s48_value handle_type, s48_value handle)
|
|||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
{
|
||||
S48_RECORD_SET(diag_rec, SR_ODBC_DIAG_SQL_STATE, s48_enter_integer(sql_state));
|
||||
S48_RECORD_SET(diag_rec, SR_ODBC_DIAG_NATIVE_ERROR, s48_enter_string(native_error));
|
||||
S48_RECORD_SET(diag_rec, SR_ODBC_DIAG_SQL_STATE, s48_enter_string(sql_state));
|
||||
S48_RECORD_SET(diag_rec, SR_ODBC_DIAG_NATIVE_ERROR, s48_enter_integer(native_error));
|
||||
S48_RECORD_SET(diag_rec, SR_ODBC_DIAG_MESSAGE, s48_enter_string(message));
|
||||
|
||||
res = s48_cons(diag_rec, res);
|
||||
break;
|
||||
}
|
||||
case SQL_NO_DATA:
|
||||
{
|
||||
more_recs = 0;
|
||||
break;
|
||||
}
|
||||
case SQL_ERROR:
|
||||
|
@ -2084,11 +2084,10 @@ s48_value odbc_sql_get_diag_recs(s48_value handle_type, s48_value handle)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
S48_GC_UNPROTECT();
|
||||
S48_GC_UNPROTECT(); /* res */
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -2266,6 +2265,8 @@ s48_value struct_to_sql_timestamp_record(SQL_TIMESTAMP_STRUCT *ts)
|
|||
|
||||
void s48_init_odbc(void)
|
||||
{
|
||||
S48_GC_PROTECT_GLOBAL(odbc_diag_record_type);
|
||||
odbc_diag_record_type = s48_get_imported_binding("odbc-diag");
|
||||
|
||||
/* PART 1 */
|
||||
S48_EXPORT_FUNCTION(odbc_alloc_environment_handle);
|
||||
|
|
Loading…
Reference in New Issue