=== modified file 'driver/execute.c' --- driver/execute.c 2009-10-07 20:43:23 +0000 +++ driver/execute.c 2009-11-30 04:22:42 +0000 @@ -508,13 +508,23 @@ to= add_to_buffer(net, to, data, length); goto out; } - /* else treat as a string */ + /* else _binary introducer for binary data */ + case SQL_BINARY: + case SQL_VARBINARY: + case SQL_LONGVARBINARY: + { + if (dbc->cxn_charset_info->number != + dbc->ansi_charset_info->number) + { + to= add_to_buffer(net, to, "_binary", 7); + } + /* We have only added the introducer, data is added below. */ + break; + } + /* else treat as a string */ case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: - case SQL_BINARY: - case SQL_VARBINARY: - case SQL_LONGVARBINARY: case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: @@ -588,12 +598,31 @@ } } - to= add_to_buffer(net,to,"'",1); - /* Make sure we have room for a fully-escaped string. */ - if (!(to= extend_buffer(net, to, length * 2))) - return 0; - to+= mysql_real_escape_string(&dbc->mysql, to, data, length); - to= add_to_buffer(net, to, "'", 1); + /* Convert binary data to hex sequence */ + if(stmt->dbc->ds->binary_to_hex_convert && + (iprec->concise_type == SQL_BINARY || + iprec->concise_type == SQL_VARBINARY || + iprec->concise_type == SQL_LONGVARBINARY)) + { + SQLINTEGER transformed_len = 0; + to= add_to_buffer(net,to," 0x",3); + /* Make sure we have room for a fully-escaped string. */ + if (!(to= extend_buffer(net, to, length * 2))) + return 0; + + copy_binhex_result(stmt, to, length * 2 + 1, &transformed_len, 0, data, length); + to += transformed_len; + } + else + { + to= add_to_buffer(net,to,"'",1); + /* Make sure we have room for a fully-escaped string. */ + if (!(to= extend_buffer(net, to, length * 2))) + return 0; + + to+= mysql_real_escape_string(&dbc->mysql, to, data, length); + to= add_to_buffer(net, to, "'", 1); + } out: if (free_data) === modified file 'setupgui/windows/odbcdialogparams.cpp' --- setupgui/windows/odbcdialogparams.cpp 2009-10-07 19:06:20 +0000 +++ setupgui/windows/odbcdialogparams.cpp 2009-12-01 06:56:20 +0000 @@ -241,6 +241,7 @@ GET_BOOL(2,dont_use_set_locale); GET_BOOL(2,pad_char_to_full_length); GET_BOOL(2,dont_cache_result); + GET_BOOL(2,binary_to_hex_convert); /* flags 3 */ GET_BOOL(3,return_table_names_for_SqlDescribeCol); GET_BOOL(3,ignore_space_after_function_names); @@ -284,6 +285,7 @@ SET_BOOL(2,dont_use_set_locale); SET_BOOL(2,pad_char_to_full_length); SET_BOOL(2,dont_cache_result); + SET_BOOL(2,binary_to_hex_convert); /* flags 3 */ SET_BOOL(3,return_table_names_for_SqlDescribeCol); SET_BOOL(3,ignore_space_after_function_names); === modified file 'setupgui/windows/odbcdialogparams.rc' --- setupgui/windows/odbcdialogparams.rc 2009-11-01 16:26:25 +0000 +++ setupgui/windows/odbcdialogparams.rc 2009-12-01 07:02:05 +0000 @@ -97,6 +97,8 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,87,127,10 CONTROL "Don't cache results of forward-only cursors",IDC_CHECK_dont_cache_result, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,102,154,10 + CONTROL "Convert raw binary data to hex constants for INSERT",IDC_CHECK_binary_to_hex_convert, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,117,194,10 END IDD_TAB3 DIALOGEX 0, 0, 209, 151 === modified file 'setupgui/windows/resource.h' --- setupgui/windows/resource.h 2009-10-07 19:06:20 +0000 +++ setupgui/windows/resource.h 2009-11-30 07:00:06 +0000 @@ -86,6 +86,7 @@ #define IDC_EDIT_sslcipher 10035 #define IDC_CHECK_handle_binary_as_char 10036 #define IDC_CHECK_save_queries 10037 +#define IDC_CHECK_binary_to_hex_convert 10038 #define IDC_BUTTON_TEST 11014 #define IDC_BUTTON_HELP 11015 #define IDC_STATIC -1 === modified file 'util/installer.c' --- util/installer.c 2009-05-02 20:53:50 +0000 +++ util/installer.c 2009-11-30 05:55:53 +0000 @@ -156,6 +156,8 @@ {'N','O','_','B','I','N','A','R','Y','_','R','E','S','U','L','T',0}; static SQLWCHAR W_DFLT_BIGINT_BIND_STR[]= {'D','F','L','T','_','B','I','G','I','N','T','_','B','I','N','D','_','S','T','R',0}; +static SQLWCHAR W_BIN_HEX_CONVERT[]= + {'B','I','N','_','H','E','X','_','C','O','N','V','E','R','T',0}; /* DS_PARAM */ /* externally used strings */ const SQLWCHAR W_DRIVER_PARAM[]= {';', 'D', 'R', 'I', 'V', 'E', 'R', '=', 0}; @@ -182,7 +184,8 @@ W_FORWARD_CURSOR, W_AUTO_RECONNECT, W_AUTO_IS_NULL, W_ZERO_DATE_TO_MIN, W_MIN_DATE_TO_ZERO, W_MULTI_STATEMENTS, W_COLUMN_SIZE_S32, - W_NO_BINARY_RESULT, W_DFLT_BIGINT_BIND_STR}; + W_NO_BINARY_RESULT, W_DFLT_BIGINT_BIND_STR, + W_BIN_HEX_CONVERT}; static const int dsnparamcnt= sizeof(dsnparams) / sizeof(SQLWCHAR *); /* DS_PARAM */ @@ -789,6 +792,8 @@ *booldest= &ds->handle_binary_as_char; else if (!sqlwcharcasecmp(W_DFLT_BIGINT_BIND_STR, param)) *booldest= &ds->default_bigint_bind_str; + else if (!sqlwcharcasecmp(W_BIN_HEX_CONVERT, param)) + *booldest= &ds->binary_to_hex_convert; /* DS_PARAM */ } @@ -1223,6 +1228,7 @@ if (ds_add_intprop(ds->name, W_COLUMN_SIZE_S32, ds->limit_column_size)) goto error; if (ds_add_intprop(ds->name, W_NO_BINARY_RESULT, ds->handle_binary_as_char)) goto error; if (ds_add_intprop(ds->name, W_DFLT_BIGINT_BIND_STR, ds->default_bigint_bind_str)) goto error; + if (ds_add_intprop(ds->name, W_BIN_HEX_CONVERT, ds->binary_to_hex_convert)) goto error; /* DS_PARAM */ === modified file 'util/installer.h' --- util/installer.h 2009-05-02 20:53:50 +0000 +++ util/installer.h 2009-11-30 04:19:16 +0000 @@ -110,6 +110,7 @@ BOOL auto_reconnect; BOOL auto_increment_null_search; BOOL handle_binary_as_char; + BOOL binary_to_hex_convert; /* flags 2 */ BOOL dont_prompt_upon_connect; BOOL dynamic_cursor;