Both the Maria and the MySQL documentation describe the return value of the mysql_real_query function:
"Zero for success. Nonzero if an error occurred. "
The current implementation breaks the API but is also not consistent:
create table t1 (a int primary key);
|
create table t2 (a int);
|
insert into t1 values (1),(2),(3);
|
insert into t2 values select a from t1;
|
/* this will return an error */
|
rc= mysql_real_query(mysql, SL("SELECT a FROM t1 WERE a= (SELECT a FROM t1))");
|
/* this wil lnot return an error */
|
rc= mysql_real_query(mysql, SL("SELECT a FROM t2 WHERE a=(SELECT a FROM t2))");
|
Also the documentation for mysql_field_count states, that this function should be used to determine if a previously exceuted statement produced a result set. In Connectors we use this to allocate buffers before processing the resultset. It doesn't make sense to allocate buffers for processing result set if an error instead of a result set will follow.
The current implementation is not only inconsistent, it also breaks a lot of applications.
PQExec (postgresql client library) for example returns an error immediately with and without index.
georg, don't SELECT also sends metadata and then an error in case of error, what is wrong here?