From: Kemet Date: May 17 2011 8:38pm Subject: SOLVED: SSQLS with BINARY column is only escaped when defined as "NOT NULL" List-Archive: http://lists.mysql.com/plusplus/9348 Message-Id: <00495E2785FD4DCCB2040832B17E53A5@PCWillemQ> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit So I entered the bug forest as you suggested. What wondered me was that the quoting was always correct (for both the normal type and the "nullable" type), only escaping was different. So I tracked down quote_q and escape_q in type_info.cpp: bool mysql_type_info::quote_q() const { const type_info& ti = base_type().c_type(); return ti == typeid(string) || ti == typeid(sql_date) || ti == typeid(sql_time) || ti == typeid(sql_datetime) || ti == typeid(sql_blob) || ti == typeid(sql_tinyblob) || ti == typeid(sql_mediumblob) || ti == typeid(sql_longblob) || ti == typeid(sql_char) || ti == typeid(sql_set); } bool mysql_type_info::escape_q() const { const type_info& ti = c_type(); return ti == typeid(string) || ti == typeid(sql_enum) || ti == typeid(sql_blob) || ti == typeid(sql_tinyblob) || ti == typeid(sql_mediumblob) || ti == typeid(sql_longblob) || ti == typeid(sql_char) || ti == typeid(sql_varchar); } First line of each function retrieves the c_type of the current object (to check it then against the typeid's that need quoting or escaping respectively). But in the quote_q() function, it uses base_type().c_type() instead of plain c_type() as in the escape_q(). And that causes a correct check ("Null" and "sql_blob" will both return type of "sql_blob" with that base_type() added). I modified the first line of the escape_q() function to the same as in the quote_q() function and recompiled. Reran my code, and hip-hip-hurray, it works like a charm now (Null gets escaped when building the query) ! I hope someone can submit a patch for this (function escape_q() is last function in type_info.cpp).