Ver Fonte

revert compatibility with mysql8

Olivier Massot há 5 anos atrás
pai
commit
d82210bd29
1 ficheiros alterados com 5 adições e 30 exclusões
  1. 5 30
      clonedb.py

+ 5 - 30
clonedb.py

@@ -318,8 +318,7 @@ class CloningOperation:
                     f"--max-allowed-packet={MAX_ALLOWED_PACKET}",
                     "--skip-add-drop-table",
                     "--skip-add-locks",
-                    "--skip-comments",
-                    "--column-statistics=0"
+                    "--skip-comments"
                     ]
 
         if self.compress:
@@ -365,23 +364,11 @@ class CloningOperation:
             cmd.append("--compress")
         return cmd
 
-    @staticmethod
-    def _clean_sql(bin_cmd, encoding):
-        """ clean some old sql declaration from mysql 5 in order to preserve
-            a compatibility between servers"""
-        cmd = bin_cmd.decode('latin')
-
-        # To ensure compatibility between mysql5 and 8+
-        cmd = re.sub(",?NO_AUTO_CREATE_USER", "", cmd)
-
-        return cmd.encode('latin')
-
     @staticmethod
     def _run_piped_processes(
             dump_cmd,
             restore_cmd,
-            tbl_count,
-            encoding):
+            tbl_count):
         """ Run the dump and the restore commands by piping them
         The output of the mysqldump process is piped into the input of the mysql one
         """
@@ -395,9 +382,7 @@ class CloningOperation:
             with Popen(restore_cmd, stdin=PIPE, stdout=mysql_handler, stderr=mysql_handler) as mysql:
                 # noinspection PyTypeChecker
                 with Popen(dump_cmd, stdout=PIPE, stderr=mysqldump_handler) as mysqldump:
-                    cmd = mysqldump.stdout.read()
-                    cmd = CloningOperation._clean_sql(cmd, encoding)
-                    mysql.stdin.write(cmd)
+                    mysql.stdin.write(mysqldump.stdout.read())
 
             if mysqldump.returncode:
                 raise RuntimeError('mysqldump returned a non zero code')
@@ -473,20 +458,12 @@ class CloningOperation:
             self.to_server.exec_query(f"CREATE SCHEMA `{self.dbname}`;")
             self.to_server.set_active_db(self.dbname)
 
-            # Following is to avoid conflict between mysql 5 and mysql 8+
-            # (@see https://stackoverflow.com/questions/50336378/variable-sql-mode-cant-be-set-to-the-value-of-no-auto-create-user)
-            self.to_server.exec_query(f"SET GLOBAL log_bin_trust_function_creators = 1;")
-
             # Grant admin users if any
             for user in self.grant:
                 self.to_server.exec_query(
                     f"GRANT ALL ON {self.dbname}.* TO '{user.username}'@'{user.host}';"
                 )
 
-            # charsets
-            charset = self.from_server.get_db_charset(self.dbname)
-            encoding = CHARSET_TO_ENCODING[charset]
-
             # Run mysqldump
             try:
                 if dump_structure_for:
@@ -494,8 +471,7 @@ class CloningOperation:
                     self._run_piped_processes(
                         dump_structure_cmd,
                         restore_cmd,
-                        len(dump_structure_for),
-                        encoding
+                        len(dump_structure_for)
                     )
 
                 if dump_data_for:
@@ -503,8 +479,7 @@ class CloningOperation:
                     self._run_piped_processes(
                         dump_data_cmd,
                         restore_cmd,
-                        len(dump_data_for),
-                        encoding
+                        len(dump_data_for)
                     )
 
                 logger.info(f"Cloning views...")