Bug #112851 Use of deprecated attribute is incomplete
Submitted: 27 Oct 2023 6:23 Modified: 27 Oct 2023 6:39
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:8.2.0 OS:Any
Assigned to: CPU Architecture:Any

[27 Oct 2023 6:23] Daniël van Eeden
Description:
https://dev.mysql.com/doc/relnotes/mysql/8.2/en/news-8-2-0.html#mysqld-8-2-0-capi lists these as deprecated:

- `mysql_ssl_set()`
- `mysql_stmt_bind_param()`

However only one of them has been marked with the deprecated attribute in the mysql.h header file. In addition to that the attribute is only used for C++ and not for C.

See also:

- https://en.cppreference.com/w/cpp/language/attributes/deprecated
- https://en.cppreference.com/w/c/language/attributes/deprecated 

This makes it more difficult to find out if a program is using any deprecated parts of the API.

How to repeat:
[dvaneeden@dve-carbon ~]$ cat mysql_deprecated.cc
#include <mysql.h>

int main() {
	MYSQL *mysql;
	MYSQL_STMT *stmt;
	MYSQL_BIND *bind;

  	mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL);
  	mysql_stmt_bind_param(stmt, bind);
}
[dvaneeden@dve-carbon ~]$ cp mysql_deprecated.cc mysql_deprecated.c
[dvaneeden@dve-carbon ~]$ gcc $(mysql_config --cflags --libs) mysql_deprecated.c
[dvaneeden@dve-carbon ~]$ g++ $(mysql_config --cflags --libs) mysql_deprecated.cc 
mysql_deprecated.cc: In function ‘int main()’:
mysql_deprecated.cc:8:22: warning: ‘bool mysql_ssl_set(MYSQL*, const char*, const char*, const char*, const char*, const char*)’ is deprecated: Use mysql_options() instead. [-Wdeprecated-declarations]
    8 |         mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL);
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from mysql_deprecated.cc:1:
/usr/include/mysql/mysql.h:465:1: note: declared here
  465 | mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca,
      | ^~~~~~~~~~~~~

Suggested fix:
Use the deprecated attribute on all parts of the API that are deprecated. And when possible for both C and C++.
[27 Oct 2023 6:39] MySQL Verification Team
Hello Daniël,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh