List:General Discussion« Previous MessageNext Message »
From:Pete Wilson Date:April 8 2009 8:52pm
Subject:success return from mysql_query() when error return was expected
View as plain text  

Hi everyone --

I'm a MySQL noob. I have MySQL queries in my C code and I was surprised to find I'm
getting a success return from:

  mysql_query(pmysql, "select * from usrs where(usr=\"illegal name\"");

In this table called "usrs," "usr" is the primary key and the engine is myisam. I expected
an error return from this query on "illegal name," which is not in the table.

An error is not returned until I call:

  prow = mysql_fetch_row(pmysqlres));

which returns NULL, which is great. 

If I run that same select from the command line, I see:

  mysql> select * from usrs where (usr="illegal name");
  Empty set (0.00 sec)

My question, finally: Is this response to my program call expected and normal for MySQL? I
suppose it is, but I just want to make sure that the behavior is OK, that indeed the
program call to mysql_query(select ...) must always in these circumstances return
success.

Thanks!

-- Pete Wilson


      
Thread
success return from mysql_query() when error return was expectedPete Wilson8 Apr
  • Re: success return from mysql_query() when error return wasexpectedThomas Spahni9 Apr