def METHOD_NAME(cursor, get_new_version):
    """
    Increment the **user version** field in a database using the given cursor.
    :param (int -> int) get_new_version: Given the current version, return the
        new version to write to the database.  The new version must fit in a
        signed 4 byte integer.
    :see: https://www.sqlite.org/pragma.html#pragma_user_version
    """
    def get_version(cursor):
        cursor.execute("PRAGMA [user_version]")
        [(version,)] = cursor.fetchall()
        return version
    version = get_version(cursor)
    new_version = get_new_version(version)
    # You cannot use bind arguments with PRAGMA. :/
    cursor.execute("PRAGMA [user_version] = {}".format(new_version))
    stored_version = get_version(cursor)
    if stored_version != new_version:
        # If it was the wrong type or if it was out of bounds then the pragma
        # will silently fail, possibly setting the stored version to 0.
        raise ValueError(
            "Failed to record new user_version {!r} (stored {!r})".format(
                new_version,
                stored_version,
            ),
        )