Angus,

On Sat, Dec 27, 2003 at 11:09:54AM -0500, Angus March wrote:
> > On Fri, Dec 26, 2003 at 09:35:42PM -0500, Angus March wrote:
> http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_real_query
> > > The quote I'm thinking of is:
> > >  You must use mysql_real_query() rather than mysql_query() for queries
> that
> > > contain binary data, because binary data may contain the `\0' character
> > >
> >
> > That's a confusing statement IMHO. It may not be necessary to escape the
> > NUL character, but you still need to create a valid query. There is no
> > way to do that other than putting your binary data into a quoted string
> > in your query. Again, how would the MySQL parser see where your binary
> > data ends? How would the parser distinguish two binary values from one
> 
>     By using the length parameter in the mysql_real_query() header.
> 

The single length parameter would pass the total length of the query
string, not the length of each (or any) of its binary values.


> > You might want to look at the example at this URL:
> >
> >
> http://www.mysql.com/documentation/mysql/bychapter/index.html#mysql_real_escape_string
> 
>     I didn't notice this function before. That and mysql_real_query() don't
> seem to be written with each other in mind. It even encodes the '\0', which
> mysql_real_query() is said to be able to deal w/. In fact, why should I need
> to use mysql_real_query() over mysql_query() if I use
> mysql_real_escape_string()?

Right. I guess you would only need mysql_real_query if you do your own
escaping without escaping NUL characters or if you want to save a few
CPU cycles and already know the length. Look at the implementation of
mysql_query:

int STDCALL
mysql_query(MYSQL *mysql, const char *query)
{
  return mysql_real_query(mysql,query, (uint) strlen(query));
}


>     Well, whatever the reason, I guess this is what API guys are expected to
> use. I'll try that and see how it goes.
> 

Regards,

Fred.

-- 
Fred van Engen                              XB Networks B.V.
email: [EMAIL PROTECTED]                Televisieweg 2
tel: +31 36 5462400                         1322 AC  Almere
fax: +31 36 5462424                         The Netherlands

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to