print("ERROR: %s" % e.errmsg) sys.exit(1) if res is None: check_failed = None elif not res: check_failed = True else: # Compare specified databases. arg_regexp = re.compile(r'{0}(?:(?:\:){0})?'.format(REGEXP_OBJ_NAME)) for db in args: # Split the database names considering backtick quotes grp = arg_regexp.match(db) if not grp: parser.error(PARSE_ERR_DB_PAIR.format(db_pair=db, db1_label='db1', db2_label='db2')) parts = grp.groups() matched_size = len(parts[0]) if not parts[1]: parts = (parts[0], parts[0]) else: # add 1 for the separator ':' matched_size += 1 matched_size += len(parts[1]) # Verify if the size of the databases matched by the REGEX is equal # to the initial specified string. In general, this identifies the # missing use of backticks. if matched_size != len(db): parser.error(PARSE_ERR_DB_PAIR_EXT.format(db_pair=db, db1_label='db1',
arg_regex_dest = db_name_regex if "ANSI_QUOTES" in dest_sql_mode: arg_regex_dest = db_name_regex_aq arg_regexp = re.compile(r"{0}(?:(?::){1})?".format(arg_regex_src, arg_regex_dest)) # Build list of databases to copy db_list = [] for db in args: # Split the database names considering backtick quotes grp = arg_regexp.match(db) if not grp: parser.error(PARSE_ERR_DB_PAIR.format(db_pair=db, db1_label='orig_db', db2_label='new_db')) db_entry = grp.groups() orig_db, new_db = db_entry # Verify if the size of the databases matched by the REGEX is equal to # the initial specified string. In general, this identifies the missing # use of backticks. matched_size = len(orig_db) if new_db: # add 1 for the separator ':' matched_size += 1 matched_size += len(new_db) if matched_size != len(db): parser.error(PARSE_ERR_DB_PAIR_EXT.format(db_pair=db, db1_label='orig_db',
# Operations to perform: # 1) databases exist # 2) check object counts # 3) check object differences # 4) check row counts among the tables # 5) check table data consistency res = True check_failed = False for db in args: # Split the database names considering backtick quotes grp = re.match(r"(`(?:[^`]|``)+`|\w+)(?:(?:\:)(`(?:[^`]|``)+`|\w+))?", db) if not grp: parser.error(PARSE_ERR_DB_PAIR.format(db_pair=db, db1_label='db1', db2_label='db2')) parts = grp.groups() matched_size = len(parts[0]) if not parts[1]: parts = (parts[0], parts[0]) else: # add 1 for the separator ':' matched_size = matched_size + 1 matched_size = matched_size + len(parts[1]) # Verify if the size of the databases matched by the REGEX is equal to the # initial specified string. In general, this identifies the missing use # of backticks. if matched_size != len(db): parser.error(PARSE_ERR_DB_PAIR_EXT.format(db_pair=db, db1_label='db1',
# Check to see if attempting to use --rpl on the same server if (opt.rpl_mode or opt.rpl_user) and source_values == dest_values: parser.error("You cannot use the --rpl option for copying on the " "same server.") # Check replication options check_rpl_options(parser, opt) # Build list of databases to copy db_list = [] for db in args: # Split the database names considering backtick quotes grp = re.match(r"(`(?:[^`]|``)+`|\w+)(?:(?:\:)(`(?:[^`]|``)+`|\w+))?", db) if not grp: parser.error(PARSE_ERR_DB_PAIR.format(db_pair=db, db1_label='orig_db', db2_label='new_db')) db_entry = grp.groups() orig_db, new_db = db_entry # Verify if the size of the databases matched by the REGEX is equal to the # initial specified string. In general, this identifies the missing use # of backticks. matched_size = len(orig_db) if new_db: # add 1 for the separator ':' matched_size = matched_size + 1 matched_size = matched_size + len(new_db) if matched_size != len(db): parser.error(PARSE_ERR_DB_PAIR_EXT.format(db_pair=db, db1_label='orig_db',
parser.error("Destination connection values invalid: " "{0}.".format(err.errmsg)) # Check to see if attempting to use --rpl on the same server if (opt.rpl_mode or opt.rpl_user) and source_values == dest_values: parser.error("You cannot use the --rpl option for copying on the " "same server.") # Check replication options check_rpl_options(parser, opt) # Build list of databases to copy db_list = [] for db in args: # Split the database names considering backtick quotes grp = re.match(r"(`(?:[^`]|``)+`|\w+)(?:(?::)(`(?:[^`]|``)+`|\w+))?", db) if not grp: parser.error(PARSE_ERR_DB_PAIR.format(db_pair=db, db1_label="orig_db", db2_label="new_db")) db_entry = grp.groups() orig_db, new_db = db_entry # Verify if the size of the databases matched by the REGEX is equal to # the initial specified string. In general, this identifies the missing # use of backticks. matched_size = len(orig_db) if new_db: # add 1 for the separator ':' matched_size += 1 matched_size += len(new_db) if matched_size != len(db): parser.error( PARSE_ERR_DB_PAIR_EXT.format( db_pair=db, db1_label="orig_db", db2_label="new_db", db1_value=orig_db, db2_value=new_db