def copy_column_constraints(func):
    """
    Decorates column operation functions for MySQL.
    Determines existing constraints and copies them to a new column
    """
    def _column_cp(self, table_name, column_old, column_new, *args, **opts):
        # Copy foreign key constraint
        try:
            constraint = self._find_foreign_constraints(
                table_name, column_old)[0]
            refs = self._lookup_constraint_references(table_name, constraint)
            if refs is not None:
                (ftable, fcolumn) = refs
                if ftable and fcolumn:
                    fk_sql = self.foreign_key_sql(
                        table_name, column_new, ftable, fcolumn)
                    get_logger().debug("Foreign key SQL: " + fk_sql)
                    self.add_deferred_sql(fk_sql)
        except __HOLE__:
            pass  # No constraint exists so ignore
        except DryRunError:
            pass
        # Copy constraints referring to this column
        try:
            reverse = self._lookup_reverse_constraint(table_name, column_old)
            for cname, rtable, rcolumn in reverse:
                fk_sql = self.foreign_key_sql(
                        rtable, rcolumn, table_name, column_new)
                self.add_deferred_sql(fk_sql)
        except DryRunError:
            pass
        return func(self, table_name, column_old, column_new, *args, **opts)
    return _column_cp
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/South-1.0.2/south/db/mysql.py/copy_column_constraints