Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2.17
Description
GCC 11.2.0 reported the following warning for CMAKE_BUILD_TYPE=RelWithDebInfo:
10.2 fda704c82c982c554ca0f0d28cb08ca972c4ddd9 |
/mariadb/10.2o/sql/table.h: In function 'bool dispatch_command(enum_server_command, THD*, char*, uint, bool, bool)':
|
/mariadb/10.2o/sql/table.h:1915:14: warning: 'db.st_mysql_lex_string::length' may be used uninitialized in this function [-Wmaybe-uninitialized]
|
1915 | db_length= db_length_arg;
|
| ~~~~~~~~~^~~~~~~~~~~~~~~
|
/mariadb/10.2o/sql/sql_parse.cc:1935:16: note: 'db.st_mysql_lex_string::length' was declared here
|
1935 | LEX_STRING db;
|
| ^~
|
The reason for this is that THD::copy_db_to() may return false even when it is not assigning db:
if (thd->copy_db_to(&db.str, &db.length)) |
break; |
The following fixes that:
diff --git a/sql/sql_class.h b/sql/sql_class.h
|
index 50ab3c56ca9..5f871f9caf6 100644
|
--- a/sql/sql_class.h
|
+++ b/sql/sql_class.h
|
@@ -4003,10 +4003,8 @@ class THD :public Statement,
|
for any CTE references.
|
*/
|
if (!lex->with_cte_resolution)
|
- {
|
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
- return TRUE;
|
- }
|
+ return TRUE;
|
}
|
else
|
{ |
It is unclear whether this bug has any impact on 10.2, because the invocation that GCC 11 complained about is in the handling of COM_FIELD_LIST, which is almost dead code. As far as I can tell, that code is only used in the embedded server implementation of mysql_list_fields().
In 10.3 and later, the function THD::copy_db_to() already returned true in this case.
Attachments
Issue Links
- is caused by
-
MDEV-16473 WITH statement throws 'no database selected' error
- Closed