zhiqiang-hhhh opened a new pull request, #22868:
URL: https://github.com/apache/doris/pull/22868

   ## Proposed changes
   
   Add an internal database with name 'mysql' to improve compatibility with 
mysqldump.
   
   <!--Describe your changes.-->
   
   ## Further comments
   
   When using mysqldump to dump all databases from mysql, users will add a 
command line arguements `--all-databases` to avoid adding expatiatory names.
   
   According to source code of mysql dump (version 8.1), target server must 
have a database with name 'mysql' to make things work if we using 
`--all-databases`
   ```cpp
   // mysqldump.cc
   static int dump_all_databases() {
       ...
       uint db_cnt = 0, cnt = 0
       uint mysql_db_found = 0;
       ...
       if (mysql_query_with_error_report(mysql, &tableres, "SHOW DATABASES"))
       ...
       while ((row = mysql_fetch_row(tableres))) {
           ...
           if (mysql_db_found || (!my_strcasecmp(charset_info, row[0], 
"mysql"))) {
               if (dump_all_tables_in_db(row[0])) result = 1;
               mysql_db_found = 1;
               /*
                   once mysql database is found dump all dbs saved as part
                   of database_list
               */
               for (; cnt < db_cnt; cnt++) {
                   if (dump_all_tables_in_db(database_list[cnt])) result = 1;
                   my_free(database_list[cnt]);
               }
           } else {
               /*
                   till mysql database is not found save database names to
                   database_list
               */
               database_list[db_cnt] =
                   my_strdup(PSI_NOT_INSTRUMENTED, row[0], MYF(MY_WME | 
MY_ZEROFILL));
               db_cnt++;
           }
       }
       assert(mysql_db_found);
       ...
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to