LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File otp-R15B03-1-lib-odbc.patch of Package erlang (Project home:Ledest:erlang:R15)

 lib/odbc/c_src/odbcserver.c | 167 ++++++++++++++++++++------------------------
 1 file changed, 76 insertions(+), 91 deletions(-)

diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index 6d44600..1980bca 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -104,6 +104,8 @@
 
 #ifdef UNIX
 #include <unistd.h>
+#include <ctype.h>
+#include <arpa/inet.h>
 #endif 
 
 #if defined WIN32
@@ -265,14 +267,14 @@ static void str_tolower(char *str, int len);
 
 int main(void)
 {
-    byte *msg = NULL;
-    char *temp = NULL, *supervisor_port = NULL, *odbc_port = NULL;
+    char *msg;
+    char *temp, *supervisor_port, *odbc_port;
     size_t length;
 #ifdef WIN32
     _setmode(_fileno( stdin),  _O_BINARY);
 #endif
     
-    msg = receive_erlang_port_msg();
+    msg = (char*)receive_erlang_port_msg();
 
     temp = strtok(msg, ";");
     length = strlen(temp);
@@ -476,7 +478,7 @@ static db_result_msg db_connect(byte *args, db_state *state)
 	diagnos = get_diagnos(SQL_HANDLE_DBC, connection_handle(state));
 	strcat((char *)diagnos.error_msg,
 	       " Connection to database failed.");
-	msg = encode_error_message(diagnos.error_msg);
+	msg = encode_error_message((char*)diagnos.error_msg);
     
 	if(!sql_success(SQLFreeHandle(SQL_HANDLE_DBC,
 				      connection_handle(state))))
@@ -496,7 +498,6 @@ static db_result_msg db_connect(byte *args, db_state *state)
 /* Close the connection to the database. Returns an ok or error message. */
 static db_result_msg db_close_connection(db_state *state)
 {
-    int index;
     SQLRETURN result;
     diagnos diagnos;
 
@@ -508,7 +509,7 @@ static db_result_msg db_close_connection(db_state *state)
                        
     if (!sql_success(result)) {
 	diagnos = get_diagnos(SQL_HANDLE_DBC, connection_handle(state));
-	return encode_error_message(diagnos.error_msg);
+	return encode_error_message((char*)diagnos.error_msg);
     }
 
     if(!sql_success(SQLFreeHandle(SQL_HANDLE_DBC,
@@ -535,7 +536,7 @@ static db_result_msg db_end_tran(byte compleationtype, db_state *state)
 
     if (!sql_success(result)) {
 	diagnos = get_diagnos(SQL_HANDLE_DBC, connection_handle(state));
-	return encode_error_message(diagnos.error_msg);
+	return encode_error_message((char*)diagnos.error_msg);
     } else {
 	return encode_atom_message("ok");
     }
@@ -545,11 +546,7 @@ static db_result_msg db_end_tran(byte compleationtype, db_state *state)
    erlang term into the message buffer of the returned message-struct. */
 static db_result_msg db_query(byte *sql, db_state *state)
 {
-    char *atom;
-    int num_of_rows, elements, update;
-    SQLSMALLINT num_of_columns;
     SQLRETURN result;
-    SQLINTEGER RowCountPtr;
     db_result_msg msg;
     diagnos diagnos;
     byte is_error[6];
@@ -622,7 +619,7 @@ static db_result_msg db_query(byte *sql, db_state *state)
 	ei_x_free(&(dynamic_buffer(state))); 
 	return msg;
     } else {
-	msg.buffer = dynamic_buffer(state).buff;
+	msg.buffer = (byte*)dynamic_buffer(state).buff;
 	msg.length = dynamic_buffer(state).index;
 	msg.dyn_alloc = TRUE;
 	return msg;
@@ -633,12 +630,9 @@ static db_result_msg db_query(byte *sql, db_state *state)
    set. */
 static db_result_msg db_select_count(byte *sql, db_state *state)
 {
-    SQLSMALLINT num_of_columns, intresult;
+    SQLSMALLINT num_of_columns;
     SQLLEN num_of_rows;
-    SQLRETURN result;
     diagnos diagnos;
-    db_result_msg msg;
-    int index;
 
     if (associated_result_set(state)) {
 	clean_state(state);
@@ -661,7 +655,7 @@ static db_result_msg db_select_count(byte *sql, db_state *state)
     if(!sql_success(SQLExecDirect(statement_handle(state), sql, SQL_NTS))) {
 	diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
 	clean_state(state);
-	return encode_error_message(diagnos.error_msg);
+	return encode_error_message((char*)diagnos.error_msg);
     }
   
     if(!sql_success(SQLNumResultCols(statement_handle(state),
@@ -746,7 +740,7 @@ static db_result_msg db_select(byte *args, db_state *state)
 	ei_x_free(&(dynamic_buffer(state))); 
 	return msg;
     } else {
-	msg.buffer = dynamic_buffer(state).buff;
+	msg.buffer = (byte*)dynamic_buffer(state).buff;
   	msg.length = dynamic_buffer(state).index; 
 	msg.dyn_alloc = TRUE;
 	return msg;
@@ -777,19 +771,19 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
 
     msg = encode_empty_message();
 
-    ei_decode_version(buffer, &index, &ver);
+    ei_decode_version((char*)buffer, &index, &ver);
     
-    ei_decode_tuple_header(buffer, &index, &size);
+    ei_decode_tuple_header((char*)buffer, &index, &size);
 
-    ei_get_type(buffer, &index, &erl_type, &size);
+    ei_get_type((char*)buffer, &index, &erl_type, &size);
 
     sql = (byte*)safe_malloc((sizeof(byte) * (size + 1)));
-    ei_decode_string(buffer, &index, sql); 
+    ei_decode_string((char*)buffer, &index, (char*)sql); 
 
-    ei_decode_long(buffer, &index, &long_num_param_values);
+    ei_decode_long((char*)buffer, &index, &long_num_param_values);
 
     num_param_values = (SQLLEN)long_num_param_values;
-    ei_decode_list_header(buffer, &index, &cols);
+    ei_decode_list_header((char*)buffer, &index, &cols);
 
     
     init_param_statement(cols, num_param_values, state, &param_status);
@@ -807,7 +801,7 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
 	   updates/deletes that affect no rows */
 	if(!sql_success(result) &&
 	   !(result == SQL_NO_DATA && !strcmp((char *)diagnos.sqlState, INFO))) {
-		msg = encode_error_message(diagnos.error_msg);
+		msg = encode_error_message((char*)diagnos.error_msg);
 	} else {
 	    for (i = 0; i < param_status.params_processed; i++) {
 		switch (param_status.param_status_array[i]) {
@@ -822,7 +816,7 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
 		default:
 		    diagnos =
 			get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
-		    msg = encode_error_message(diagnos.error_msg);
+		    msg = encode_error_message((char*)diagnos.error_msg);
 		    i = param_status.params_processed;
 		    break;
 		}
@@ -835,7 +829,7 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
                     msg = encode_result(state);
                 }
 		if(msg.length == 0) {
-		    msg.buffer = dynamic_buffer(state).buff;
+		    msg.buffer = (byte*)dynamic_buffer(state).buff;
   		    msg.length = dynamic_buffer(state).index; 
 		    msg.dyn_alloc = TRUE;
 		} else { /* Error occurred */
@@ -874,7 +868,7 @@ static db_result_msg db_describe_table(byte *sql, db_state *state)
     SQLSMALLINT num_of_columns;
     SQLCHAR name[MAX_NAME];
     SQLSMALLINT name_len, sql_type, dec_digits, nullable;
-    SQLLEN size;
+    SQLULEN size;
     diagnos diagnos;
     int i;
     
@@ -892,7 +886,7 @@ static db_result_msg db_describe_table(byte *sql, db_state *state)
     
     if (!sql_success(SQLPrepare(statement_handle(state), sql, SQL_NTS))){
 	diagnos =  get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
-	msg = encode_error_message(diagnos.error_msg);
+	msg = encode_error_message((char*)diagnos.error_msg);
 	clean_state(state);
 	return msg;
     }
@@ -900,7 +894,7 @@ static db_result_msg db_describe_table(byte *sql, db_state *state)
     if(!sql_success(SQLNumResultCols(statement_handle(state),
 				     &num_of_columns))) {
 	diagnos =  get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
-	msg = encode_error_message(diagnos.error_msg);
+	msg = encode_error_message((char*)diagnos.error_msg);
 	clean_state(state);
 	return msg;
     }
@@ -928,7 +922,7 @@ static db_result_msg db_describe_table(byte *sql, db_state *state)
     ei_x_encode_empty_list(&dynamic_buffer(state));
     
     clean_state(state);
-    msg.buffer = dynamic_buffer(state).buff;
+    msg.buffer = (byte*)dynamic_buffer(state).buff;
     msg.length = dynamic_buffer(state).index; 
     msg.dyn_alloc = TRUE;
     return msg;
@@ -1012,7 +1006,7 @@ static db_result_msg encode_result(db_state *state)
     if(!sql_success(SQLNumResultCols(statement_handle(state), 
   				     &num_of_columns))) { 
 	    diagnos =  get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
-	    msg = encode_error_message(diagnos.error_msg);
+	    msg = encode_error_message((char*)diagnos.error_msg);
 	    clean_state(state);
 	    return msg;
     } 
@@ -1029,7 +1023,7 @@ static db_result_msg encode_result(db_state *state)
     
     if(!sql_success(SQLRowCount(statement_handle(state), &RowCountPtr))) { 
 	    diagnos =  get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
-	    msg = encode_error_message(diagnos.error_msg);
+	    msg = encode_error_message((char*)diagnos.error_msg);
 	    clean_state(state);
 	    return msg;
     }
@@ -1214,8 +1208,7 @@ static db_result_msg encode_column_name_list(SQLSMALLINT num_of_columns,
     db_result_msg msg;
     SQLCHAR name[MAX_NAME];
     SQLSMALLINT name_len, sql_type, dec_digits, nullable;
-    SQLLEN size; 
-    SQLRETURN result;
+    SQLULEN size;
 
     msg = encode_empty_message();
     
@@ -1259,7 +1252,7 @@ static db_result_msg encode_column_name_list(SQLSMALLINT num_of_columns,
 			DO_EXIT(EXIT_BIND);
 		}
 		ei_x_encode_string_len(&dynamic_buffer(state),
-				       name, name_len);
+				       (char*)name, name_len);
 	    }
 	    else {
 		columns(state)[i].type.len = 0;
@@ -1277,9 +1270,8 @@ static db_result_msg encode_column_name_list(SQLSMALLINT num_of_columns,
 static db_result_msg encode_value_list(SQLSMALLINT num_of_columns,
 				       db_state *state)
 {
-    int i, msg_len;
+    int i;
     SQLRETURN result;
-    db_result_msg list_result;
     db_result_msg msg;
 
     msg = encode_empty_message();
@@ -1322,9 +1314,8 @@ static db_result_msg encode_value_list_scroll(SQLSMALLINT num_of_columns,
 					      SQLINTEGER OffSet, int N,
 					      db_state *state)
 {
-    int i, j,  msg_len;
+    int i, j;
     SQLRETURN result;
-    db_result_msg list_result;
     db_result_msg msg;
 
     msg = encode_empty_message();
@@ -1589,11 +1580,11 @@ static Boolean decode_params(db_state *state, byte *buffer, int *index, param_ar
     TIMESTAMP_STRUCT* ts;
     char atomarray[MAXATOMLEN+1];
     
-    ei_get_type(buffer, index, &erl_type, &size);
+    ei_get_type((char*)buffer, index, &erl_type, &size);
     param = &(*params)[i];
 
     if(erl_type == ERL_ATOM_EXT) {
-	ei_decode_atom(buffer, index, atomarray);
+	ei_decode_atom((char*)buffer, index, atomarray);
 	if(strncmp(atomarray, "null", 4) == 0 ) {
 	    param->offset += param->type.len;
 
@@ -1607,36 +1598,33 @@ static Boolean decode_params(db_state *state, byte *buffer, int *index, param_ar
 
     switch (param->type.c) {
     case SQL_C_CHAR:
-	    if (binary_strings(state)) {
-		    ei_decode_binary(buffer, index,
+	    if (binary_strings(state))
+		    ei_decode_binary((char*)buffer, index,
 				     &(param->values.string[param->offset]), &bin_size);
-		    param->offset += param->type.len;
-	    } else {
-		    if(erl_type != ERL_STRING_EXT) {
-			    return FALSE;
-		    }
-		    ei_decode_string(buffer, index, &(param->values.string[param->offset]));
-		    param->offset += param->type.len;
-	    }
+	    else if (erl_type != ERL_STRING_EXT)
+		return FALSE;
+	    else
+		ei_decode_string((char*)buffer, index, &(param->values.string[param->offset]));
+	    param->offset += param->type.len;
 	    break;
     case SQL_C_WCHAR:
-	    ei_decode_binary(buffer, index, &(param->values.string[param->offset]), &bin_size);
+	    ei_decode_binary((char*)buffer, index, &(param->values.string[param->offset]), &bin_size);
 	    param->offset += param->type.len;
 	    break;
     case SQL_C_TYPE_TIMESTAMP:
 	    ts = (TIMESTAMP_STRUCT*) param->values.string;
-	    ei_decode_tuple_header(buffer, index, &size);
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_tuple_header((char*)buffer, index, &size);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].year = (SQLUSMALLINT)val;
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].month = (SQLUSMALLINT)val;
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].day = (SQLUSMALLINT)val;
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].hour = (SQLUSMALLINT)val;
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].minute = (SQLUSMALLINT)val;
-	    ei_decode_long(buffer, index, &val);
+	    ei_decode_long((char*)buffer, index, &val);
 	    ts[j].second = (SQLUSMALLINT)val;
 	    ts[j].fraction = (SQLINTEGER)0;
 	    break;
@@ -1648,7 +1636,7 @@ static Boolean decode_params(db_state *state, byte *buffer, int *index, param_ar
 		    return FALSE;
 	    }
 	    
-	    if(ei_decode_long(buffer, index, &l64)) {
+	    if(ei_decode_long((char*)buffer, index, &l64)) {
 		    return FALSE;
 	    }
 	    
@@ -1666,7 +1654,7 @@ static Boolean decode_params(db_state *state, byte *buffer, int *index, param_ar
 	    if((erl_type != ERL_FLOAT_EXT)) { 
 		    return FALSE;
 	    } 
-	    ei_decode_double(buffer, index, &(param->values.floating[j])); 
+	    ei_decode_double((char*)buffer, index, &(param->values.floating[j])); 
 	    break;
 	    
     case SQL_C_BIT:
@@ -2082,24 +2070,23 @@ static void init_driver(int erl_auto_commit_mode, int erl_trace_driver,
 	    DO_EXIT(EXIT_CONNECTION);
     if(!sql_success(SQLSetConnectAttr(connection_handle(state),
 				      SQL_ATTR_AUTOCOMMIT,
-				      (SQLPOINTER)auto_commit_mode, 0)))
+				      (SQLPOINTER)(intptr_t)auto_commit_mode, 0)))
 	    DO_EXIT(EXIT_CONNECTION);
     if(!sql_success(SQLSetConnectAttr(connection_handle(state),
 				      SQL_ATTR_TRACE,
-				      (SQLPOINTER)trace_driver, 0)))
+				      (SQLPOINTER)(intptr_t)trace_driver, 0)))
 	    DO_EXIT(EXIT_CONNECTION);
 }
 
 static void init_param_column(param_array *params, byte *buffer, int *index,
 			      int num_param_values, db_state* state)
 {
-    int size, erl_type;
-    long user_type, precision, scale, length, dummy;
+    long user_type, precision, scale, length;
     long in_or_out;
     
-    ei_decode_long(buffer, index, &user_type);
+    ei_decode_long((char*)buffer, index, &user_type);
 
-    params->type.strlen_or_indptr = (SQLLEN)NULL;
+    params->type.strlen_or_indptr = 0;
     params->type.strlen_or_indptr_array = NULL;
     params->type.decimal_digits = (SQLINTEGER)0;
   
@@ -2135,8 +2122,8 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
 	} else {
 	    params->type.sql = SQL_DECIMAL;
 	}
-	ei_decode_long(buffer, index, &precision);
-	ei_decode_long(buffer, index, &scale);
+	ei_decode_long((char*)buffer, index, &precision);
+	ei_decode_long((char*)buffer, index, &scale);
 	map_dec_num_2_c_column(&params->type, (int)precision, (int)scale);
 	if( params->type.c == SQL_C_SLONG) {
 	    params->values.integer =
@@ -2159,7 +2146,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
 	} else {
 	     params->type.sql = SQL_VARCHAR;
 	}
-	ei_decode_long(buffer, index, &length);
+	ei_decode_long((char*)buffer, index, &length);
 	/* Max string length + string terminator */
 	 params->type.len = length+1;
 	 params->type.c = SQL_C_CHAR;
@@ -2182,7 +2169,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
 	    default:
 		params->type.sql = SQL_WLONGVARCHAR; break;
 	}
-	ei_decode_long(buffer, index, &length);
+	ei_decode_long((char*)buffer, index, &length);
 	/* Max string length + string terminator */
 	params->type.len = (length+1)*sizeof(SQLWCHAR);
         params->type.c = SQL_C_WCHAR;
@@ -2205,7 +2192,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
 	params->type.sql = SQL_FLOAT;
 	params->type.c = SQL_C_DOUBLE;
 	params->type.len = sizeof(double);
-	ei_decode_long(buffer, index, &length);
+	ei_decode_long((char*)buffer, index, &length);
 	params->type.col_size = (SQLUINTEGER)length;
 	params->values.floating =
 	    (double *)safe_malloc(num_param_values * params->type.len);
@@ -2237,7 +2224,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
     }
     params->offset = 0;
 
-    ei_decode_long(buffer, index, &in_or_out);
+    ei_decode_long((char*)buffer, index, &in_or_out);
     switch((in_or_out_type)in_or_out){
     case(ERL_ODBC_OUT):
         out_params(state) = TRUE;
@@ -2284,7 +2271,7 @@ static void init_param_statement(int cols, SQLLEN num_param_values,
        takes either an interger or a pointer depending on the attribute */
     if(!sql_success(SQLSetStmtAttr(statement_handle(state),
 				   SQL_ATTR_PARAMSET_SIZE,
-				   (SQLLEN *)num_param_values,
+				   (SQLPOINTER)(intptr_t)num_param_values,
 				   0))) {
 	DO_EXIT(EXIT_PARAM_ARRAY);
     }
@@ -2355,21 +2342,21 @@ static db_result_msg map_sql_2_c_column(db_column* column)
     case SQL_DECIMAL:
 	map_dec_num_2_c_column(&(column -> type), column -> type.col_size,
 			       column -> type.decimal_digits);
-	column -> type.strlen_or_indptr = (SQLLEN)NULL;
+	column -> type.strlen_or_indptr = 0;
 	break;
     case SQL_TINYINT:
     case SQL_INTEGER:
     case SQL_SMALLINT:
 	column -> type.len = sizeof(SQLINTEGER);
 	column -> type.c = SQL_C_SLONG;
-	column -> type.strlen_or_indptr = (SQLLEN)NULL;
+	column -> type.strlen_or_indptr = 0;
 	break;
     case SQL_REAL:
     case SQL_FLOAT:
     case SQL_DOUBLE:
 	column -> type.len = sizeof(double);
 	column -> type.c = SQL_C_DOUBLE;
-	column -> type.strlen_or_indptr = (SQLLEN)NULL;
+	column -> type.strlen_or_indptr = 0;
 	break;
     case SQL_TYPE_DATE:
     case SQL_TYPE_TIME:
@@ -2381,17 +2368,17 @@ static db_result_msg map_sql_2_c_column(db_column* column)
     case SQL_TYPE_TIMESTAMP:
       column -> type.len = sizeof(TIMESTAMP_STRUCT);
       column -> type.c = SQL_C_TYPE_TIMESTAMP;
-      column -> type.strlen_or_indptr = (SQLLEN)NULL;
+      column -> type.strlen_or_indptr = 0;
       break;
     case SQL_BIGINT:
 	column -> type.len = DEC_NUM_LENGTH;
 	column -> type.c = SQL_C_CHAR;
-	column -> type.strlen_or_indptr = (SQLLEN)NULL;
+	column -> type.strlen_or_indptr = 0;
 	break;
     case SQL_BIT:
 	column -> type.len = sizeof(byte);
 	column -> type.c = SQL_C_BIT;
-	column -> type.strlen_or_indptr = (SQLLEN)NULL;
+	column -> type.strlen_or_indptr = 0;
 	break;
     case SQL_UNKNOWN_TYPE:
 	msg = encode_error_message("Unknown column type");
@@ -2407,8 +2394,7 @@ static param_array * bind_parameter_arrays(byte *buffer, int *index,
 					   int cols, int num_param_values,
 					   db_state *state)
 {
-    int i, j, k, size, erl_type;
-    db_result_msg msg;
+    int i, j, size, erl_type;
     long dummy;
     void *Values;
     param_array *params;
@@ -2417,25 +2403,25 @@ static param_array * bind_parameter_arrays(byte *buffer, int *index,
     
     for (i = 0; i < cols; i++) {
     
-	ei_get_type(buffer, index, &erl_type, &size);
+	ei_get_type((char*)buffer, index, &erl_type, &size);
 
 	if(erl_type == ERL_NIL_EXT) {
 	    /* End of previous list of column values when i > 0 */
-	    ei_decode_list_header(buffer, index, &size);
+	    ei_decode_list_header((char*)buffer, index, &size);
 	}
 
-	ei_decode_tuple_header(buffer, index, &size);
+	ei_decode_tuple_header((char*)buffer, index, &size);
 
 	init_param_column(&params[i], buffer, index, num_param_values, state);
 
-	ei_decode_list_header(buffer, index, &size);
+	ei_decode_list_header((char*)buffer, index, &size);
 
 	if(params[i].type.c == SQL_C_SLONG) {
          /* Get rid of the dummy value 256 that is added as the first value
 	    of all integer parameter value lists. This is to avoid that the
 	    list will be encoded as a string if all values are less
 	    than 256 */
-	    ei_decode_long(buffer, index, &dummy); 
+	    ei_decode_long((char*)buffer, index, &dummy); 
 	}
   
 	for (j = 0; j < num_param_values; j++) {
@@ -2494,7 +2480,6 @@ static db_column retrive_binary_data(db_column column, int column_nr,
 				     db_state *state)
 { 
     char *outputptr;
-    char *sqlState;
     int blocklen, outputlen, result;
     diagnos diagnos;
   
@@ -2565,7 +2550,7 @@ static db_result_msg retrive_scrollable_cursor_support_info(db_state *state)
 	ei_x_encode_atom(&dynamic_buffer(state), "false");  
 	ei_x_encode_atom(&dynamic_buffer(state), "false");
     } 
-    msg.buffer = dynamic_buffer(state).buff;
+    msg.buffer = (byte*)dynamic_buffer(state).buff;
     msg.length = dynamic_buffer(state).index; 
     msg.dyn_alloc = TRUE;
     return msg;
@@ -2596,7 +2581,7 @@ static db_result_msg more_result_sets(db_state *state)
 	diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
 	strcat((char *)diagnos.error_msg,
 	       "Failed to create on of the result sets");
-	msg = encode_error_message(diagnos.error_msg);
+	msg = encode_error_message((char*)diagnos.error_msg);
 	return msg;
     }
 }