List:MySQL++« Previous MessageNext Message »
From:Kemet Date:May 17 2011 8:38pm
Subject:SOLVED: SSQLS with BINARY column is only escaped when defined as "NOT NULL"
View as plain text  
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<sql_blob>" 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<sql_blob> 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).

Thread
SSQLS with BINARY column is sometimes not escapedKemet5 May
  • Re: SSQLS with BINARY column is sometimes not escapedWarren Young6 May
    • Re: SSQLS with BINARY column is sometimes not escapedKemet6 May
    • Re: SSQLS with BINARY column is sometimes not escapedKemet8 May
      • Re: SSQLS with BINARY column is sometimes not escapedWarren Young8 May
        • SOLVED: SSQLS with BINARY column is only escaped when defined as "NOT NULL"Kemet19 May
          • Re: SOLVED: SSQLS with BINARY column is only escaped when definedas "NOT NULL"Warren Young19 May