Bug #93662 mysqlx_result_warning_count() returns 0 while there are warnings
Submitted: 18 Dec 2018 16:32 Modified: 21 Dec 2018 7:17
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / C++ Severity:S2 (Serious)
Version:8.0.13 OS:Any
Assigned to: CPU Architecture:Any

[18 Dec 2018 16:32] Daniël van Eeden
Description:
mysqlx_result_warning_count() returns 0 for a statement what results in warnings if I run it with mysqlsh.

And mysqlx_result_next_warning() seems to have the same issue.

How to repeat:
[dvaneeden@dve-mac tmp]$ cat mysqlx_warn.c 
#include <mysqlx/xapi.h>
#include <stdio.h>

int main() {
  mysqlx_session_t *sess = mysqlx_get_session_from_url(
      "mysqlx://msandbox:msandbox@localhost/test", NULL, NULL);

  mysqlx_result_t *result = mysqlx_sql(
      sess, "SELECT DATE_SUB('1234-13-34 25:55:99.87654', INTERVAL 1 DAY)",
      MYSQLX_NULL_TERMINATED);
  printf("Warning count: %d\n", mysqlx_result_warning_count(result));

  mysqlx_session_close(sess);
}
[dvaneeden@dve-mac tmp]$ gcc -I/usr/include/mysql-cppconn-8 -lmysqlcppconn8 -o mysqlx_warn mysqlx_warn.c
[dvaneeden@dve-mac tmp]$ ./mysqlx_warn 
Warning count: 0
[dvaneeden@dve-mac tmp]$ ldd mysqlx_warn
	linux-vdso.so.1 (0x00007ffeaf0cf000)
	libmysqlcppconn8.so.1 => /lib64/libmysqlcppconn8.so.1 (0x00007f8c6c4e8000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f8c6c322000)
	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f8c6c28c000)
	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f8c6bfb2000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8c6bf90000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f8c6bdf8000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f8c6bc72000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8c6bc57000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f8c6c6ff000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f8c6bc3d000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f8c6bc37000)
[dvaneeden@dve-mac tmp]$ rpm -qf /lib64/libmysqlcppconn8.so.1
mysql-connector-c++-8.0.13-1.fc29.x86_64
[dvaneeden@dve-mac tmp]$ mysqlsh --sqlx mysqlx://msandbox:msandbox@localhost/test
mysqlsh: [Warning] Using a password on the command line interface can be insecure.
Creating an X protocol session to 'msandbox@localhost/test'
Fetching schema names for autocompletion... Press ^C to stop.
Fetching table and column names from `test` for auto-completion... Press ^C to stop.
Your MySQL connection id is 210 (X protocol)
Server version: 8.0.11 MySQL Community Server - GPL
Default schema set to `test`.
MySQL Shell 8.0.13

Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help' or '\?' for help; '\quit' to exit.

 MySQL  localhost:33060+ ssl  test  SQL > SELECT DATE_SUB('1234-13-34 25:55:99.87654', INTERVAL 1 DAY);
+-------------------------------------------------------+
| DATE_SUB('1234-13-34 25:55:99.87654', INTERVAL 1 DAY) |
+-------------------------------------------------------+
| NULL                                                  |
+-------------------------------------------------------+
1 row in set, 1 warning (0.0008 sec)
Warning (code 1292): Incorrect datetime value: '1234-13-34 25:55:99.87654'
[21 Dec 2018 7:17] Bogdan Kecman
Thanks for the report, verified as described
Bogdan