===== mysql-test/r/type_blob.result 1.56 vs edited ===== --- 1.56/mysql-test/r/type_blob.result 2007-11-19 12:34:12 -05:00 +++ edited/mysql-test/r/type_blob.result 2008-03-19 12:19:37 -04:00 @@ -821,4 +821,23 @@ LENGTH(c) CHAR_LENGTH(c) 65535 65535 65535 65535 DROP TABLE t; +DROP DATABASE IF EXISTS dbbug33048; +CREATE DATABASE dbbug33048; +use dbbug33048; +CREATE TABLE binfile (i int auto_increment primary key, bin_data LONGBLOB); +FLUSH LOGS; +INSERT INTO binfile (bin_data) values (raw value); +SELECT 'good, have failing data' as descr, i FROM binfile where bin_data = hexexpr; +descr i +good, have failing data 1 +SELECT bin_data INTO dumpfile 'bug33048-dump1' FROM binfile; +FLUSH LOGS; +DELETE FROM binfile; +SELECT bin_data INTO dumpfile 'bug33048-dump2' FROM binfile; +SELECT 'good, have failing data' as descr, i FROM binfile where bin_data = hexexpr; +descr i +good, have failing data 1 +DROP TABLE binfile; +use test; +DROP DATABASE dbbug33048; End of 5.0 tests ===== mysql-test/t/type_blob.test 1.35 vs edited ===== --- 1.35/mysql-test/t/type_blob.test 2007-11-19 12:34:12 -05:00 +++ edited/mysql-test/t/type_blob.test 2008-03-19 12:44:51 -04:00 @@ -447,4 +447,51 @@ INSERT INTO t (c) VALUES (REPEAT('3',655 SELECT LENGTH(c), CHAR_LENGTH(c) FROM t; DROP TABLE t; +# +# Bug#33048: Not able to recover binary/blob data correctly using mysqlbinlog +# +--disable_warnings +DROP DATABASE IF EXISTS dbbug33048; +--enable_warnings +CREATE DATABASE dbbug33048; + +use dbbug33048; +CREATE TABLE binfile (i int auto_increment primary key, bin_data LONGBLOB); + +FLUSH LOGS; +let $hexrepr=x'400d0a0d0d0a0a0d3e30303d002030313d012030323d022030333d032030343d042030353d052030363d062030373d072030383d082030393d092030613d0a2030623d0b2030633d0c2030643d0d2030653d0e2030663d0f2031303d102031313d112031323d122031333d132031343d142031353d152031363d162031373d172031383d182031393d192031613d1a2031623d1b2031633d1c2031643d1d2031653d1e2031663d1f2032303d202032313d212032323d222032333d232032343d242032353d252032363d262032383d282032393d292032613d2a2032623d2b2032633d2c2032643d2d2032653d2e2032663d2f2033303d302033313d312033323d322033333d332033343d342033353d352033363d362033373d372033383d382033393d392033613d3a2033623d3b2033633d3c2033643d3d2033653d3e2033663d3f2034303d402034313d412034323d422034333d432034343d442034353d452034363d462034373d472034383d482034393d492034613d4a2034623d4b2034633d4c2034643d4d2034653d4e2034663d4f2035303d502035313d512035323d522035333d532035343d542035353d552035363d562035373d572035383d582035393d592035613d5a2035623d5b2035633f3f2035643d5d2035653d5e2035663d5f2036303d602036313d612036323d622036333d632036343d642036353d652036363d662036373d672036383d682036393d692036613d6a2036623d6b2036633d6c2036643d6d2036653d6e2036663d6f2037303d702037313d712037323d722037333d732037343d742037353d752037363d762037373d772037383d782037393d792037613d7a2037623d7b2037633d7c2037643d7d2037653d7e2037663d7f2038303d802038313d812038323d822038333d832038343d842038353d852038363d862038373d872038383d882038393d892038613d8a2038623d8b2038633d8c2038643d8d2038653d8e2038663d8f2039303d902039313d912039323d922039333d932039343d942039353d952039363d962039373d972039383d982039393d992039613d9a2039623d9b2039633d9c2039643d9d2039653d9e2039663d9f2061303da02061313da12061323da22061333da32061343da42061353da52061363da62061373da72061383da82061393da92061613daa2061623dab2061633dac2061643dad2061653dae2061663daf2062303db02062313db12062323db22062333db32062343db42062353db52062363db62062373db72062383db82062393db92062613dba2062623dbb2062633dbc2062643dbd2062653dbe2062663dbf2063303dc02063313dc12063323dc22063333dc32063343dc42063353dc52063363dc62063373dc72063383dc82063393dc92063613dca2063623dcb2063633dcc2063643dcd2063653dce2063663dcf2064303dd02064313dd12064323dd22064333dd32064343dd42064353dd52064363dd62064373dd72064383dd82064393dd92064613dda2064623ddb2064633ddc2064643ddd2064653dde2064663ddf2065303de02065313de12065323de22065333de32065343de42065353de52065363de62065373de72065383de82065393de92065613dea2065623deb2065633dec2065643ded2065653dee2065663def2066303df02066313df12066323df22066333df32066343df42066353df52066363df62066373df72066383df82066393df92066613dfa2066623dfb2066633dfc2066643dfd2066653dfe2066663dff3c2040'; # contains all characters encoded except "'" and "\". + +#let $hexrepr=x'27'; # (single quote), fails +#let $hexrepr=x'5c5c74'; # (backslash, backslash, t), fails +#let $hexrepr=x'5c5c5c74'; # (backslash, backslash, backslash, t), fails +#let $hexrepr=x'5c74'; # (backslash, t), fails + +replace_regex s/x'.*'/hexexpr/; +let $blob=`select $hexrepr`; + +replace_regex /values \(.*\)/values (raw value)/; +eval INSERT INTO binfile (bin_data) values ('$blob'); +replace_regex s/x'.*'/hexexpr/; +eval SELECT 'good, have failing data' as descr, i FROM binfile where bin_data = $hexrepr; + +SELECT bin_data INTO dumpfile 'bug33048-dump1' FROM binfile; +FLUSH LOGS; +DELETE FROM binfile; + +exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=dbbug33048 $MYSQLTEST_VARDIR/log/master-bin.000002 |$MYSQL dbbug33048; + +SELECT bin_data INTO dumpfile 'bug33048-dump2' FROM binfile; +replace_regex s/x'.*'/hexexpr/; +eval SELECT 'good, have failing data' as descr, i FROM binfile where bin_data = $hexrepr; + +diff_files $MYSQLTEST_VARDIR/master-data/dbbug33048/bug33048-dump1 $MYSQLTEST_VARDIR/master-data/dbbug33048/bug33048-dump2; + +remove_file $MYSQLTEST_VARDIR/master-data/dbbug33048/bug33048-dump1; +remove_file $MYSQLTEST_VARDIR/master-data/dbbug33048/bug33048-dump2; + +DROP TABLE binfile; +use test; +DROP DATABASE dbbug33048; + +## --echo End of 5.0 tests ===== sql/log_event.cc 1.245 vs edited ===== --- 1.245/sql/log_event.cc 2007-12-21 14:30:22 -05:00 +++ edited/sql/log_event.cc 2008-03-19 12:25:08 -04:00 @@ -1857,11 +1857,74 @@ void Query_log_event::print_query_header } } +static const char * map_special_bytes_to_safe_repr[] = { + /* We assume all representations are two bytes */ +/* 0NN0 0NN1 0NN2 0NN3 0NN4 0NN5 0NN6 0NN7 */ + "\\0", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 000N */ + "\\b", "\\t", "\\n", NULL, NULL, "\\r", NULL, NULL, /* 001N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 002N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 003N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 004N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 005N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 006N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 007N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 010N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 011N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 012N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 013N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 014N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 015N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 016N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 017N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 020N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 021N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 022N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 023N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 024N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 025N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 026N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 027N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 030N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 031N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 032N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 033N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 034N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 035N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 036N */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* 037N */ +}; void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) { + const char *cursor= query; + const char * const end_of_query=query+q_len; + + const char *end_of_safe_area= cursor; + print_query_header(file, print_event_info); - my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME)); + + while (end_of_safe_area != end_of_query) + { + const char *repr; + + repr= map_special_bytes_to_safe_repr[(unsigned char) *end_of_safe_area]; + if (repr != NULL) + { + DBUG_ASSERT(2 == strlen(repr)); /* All representations are two bytes */ + if (cursor != end_of_safe_area) + my_fwrite(file, (byte*) cursor, end_of_safe_area-cursor, MYF(MY_NABP | MY_WME)); + my_fwrite(file, (byte*) repr, 2, MYF(MY_NABP | MY_WME)); + + cursor= end_of_safe_area + 1; + } + end_of_safe_area++; + } + + if (cursor != end_of_query) + my_fwrite(file, (byte*) cursor, end_of_safe_area-cursor, MYF(MY_NABP | MY_WME)); + +at_end_of_query: + fprintf(file, "\n%s\n", print_event_info->delimiter); } #endif /* MYSQL_CLIENT */