Bug #77712 mysql_real_query does not report an error for some queries!
Submitted: 14 Jul 2015 7:16 Modified: 14 Jul 2015 7:42
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:8.0.0 OS:Any
Assigned to: CPU Architecture:Any

[14 Jul 2015 7:16] Shane Bester
Description:
some failing queries report a successful result code, then client applications written according to the spec will fail to notice these errors.

mysql client itself only reports an error because it checks the first character of mysql_error() string is not null.  This is not the proper way to detect errors.

How to repeat:
read https://dev.mysql.com/doc/refman/5.7/en/mysql-real-query.html

run each of these two queries with mysql_real_query and see the difference in return codes and errors.

select polygon(linestring(point(1,1))) ;
select a ;
[14 Jul 2015 7:42] Shane Bester
Setting as verified.   See the sample program output.  Notice, if mysql_real_query returns an error,  we should not call mysql_store_result...

So why then does the polygon query only return the error after mysql_store_result ???

[x@x ~]$ ./bug77712.cpp
Connected: 127.0.0.1 via TCP/IP [5.8.0-m17-debug]

query: select polygon(linestring(point(1,1))) ;;
mysql_real_query returned: 0 - mysql_errno: 0,  mysql_error:
mysql_store_result returned: (nil) - mysql_errno: 3037,  mysql_error: Invalid GIS data provided to function linestring.

query: select a ;;
mysql_real_query returned: 1 - mysql_errno: 1054,  mysql_error: Unknown column 'a' in 'field list'
[14 Jul 2015 7:43] Shane Bester
testcase

Attachment: bug77712.cpp (text/plain), 1.73 KiB.

[14 Jul 2015 8:17] Shane Bester
just to clarify.  my wish hereis that the query
"select polygon(linestring(point(1,1)))" 

causes a nonzero return from mysql_real_query()
[3 Sep 2015 6:26] Norvald Ryeng
Posted by developer:
 
Output from attached test program when using Erik's POW() query:

query: select POW(9999, 999999);;
mysql_real_query returned: 0 - mysql_errno: 0,  mysql_error: 
mysql_store_result returned: (nil) - mysql_errno: 1690,  mysql_error: DOUBLE value is out of range in 'pow(9999,999999)'

This is not a GIS bug. I'm moving it to the optimizer category.
[18 Jun 2016 21:26] Omer Barnir
Posted by developer:
 
Reported version value updated to reflect release name change from 5.8 to 8.0