def ext_valid_update_path(cursor, ext, current_version, version):
    """
    Check to see if the installed extension version has a valid update
    path to the given version. A version of 'latest' is always a valid path.

    Return True if a valid path exists. Otherwise return False.

    Args:
      cursor (cursor) -- cursor object of psycopg2 library
      ext (str) -- extension name
      current_version (str) -- installed version of the extension.
      version (str) -- target extension version to update to.
        A value of 'latest' is always a valid path and will result
        in the extension update command always being run.
    """

    valid_path = False
    params = {}
    if version != 'latest':
        query = ("SELECT path FROM pg_extension_update_paths(%(ext)s) "
                 "WHERE source = %(cv)s "
                 "AND target = %(ver)s")

        params['ext'] = ext
        params['cv'] = current_version
        params['ver'] = version

        cursor.execute(query, params)
        res = cursor.fetchone()
        if res is not None:
            valid_path = True
    else:
        valid_path = True

    return (valid_path)