

var csvParseRegExp = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/;



SELECT u.table_name, u.constraint_name, u.ordinal_position, u.column_name, u.referenced_table_name, u.referenced_column_name
        FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
        WHERE u.table_schema = DATABASE() AND u.referenced_table_name IS NOT NULL
        ORDER BY u.table_name, u.constraint_name, u.ordinal_position, u.referenced_table_name

SELECT u.table_name, u.constraint_name, u.ordinal_position, u.column_name, u.referenced_table_name, u.referenced_column_name
        FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
            JOIN INFORMATION_SCHEMA.`COLUMNS` a ON a.table_name=u.table_name AND a.column_name=u.column_name AND a.table_schema = DATABASE()
            JOIN INFORMATION_SCHEMA.`COLUMNS` b ON b.table_name=u.referenced_table_name AND b.column_name=u.referenced_column_name AND b.table_schema = DATABASE()
        WHERE u.table_schema = DATABASE() AND u.referenced_table_name IS NOT NULL
            AND (a.COLLATION_NAME<>b.COLLATION_NAME OR a.CHARACTER_SET_NAME<>b.CHARACTER_SET_NAME)
        ORDER BY u.table_name, u.constraint_name, u.ordinal_position
