def _bulk_update_query_part(model, conn, key_fds, upd_fds, where):
    """
    Forms bulk update query part without values, counting that all keys and values are already in vals table
    :param model: Model to update, a subclass of django.db.models.Model
    :param conn: Database connection used
    :param key_fds: Field names, by which items would be selected (tuple)
    :param upd_fds: FieldDescriptor objects to update
    :param where: A sql, params tuple to filter query data before update
    :return: A tuple of sql and it's parameters
    """
    query = """
        UPDATE %s AS t SET %s
        FROM "vals"
        WHERE %s
    """
    db_table = model._meta.db_table
    where_items = []
    for fd in key_fds:
        table_field = '"t"."%s"' % fd.get_field(model).column
        prefixed_sel_field = '"vals"."%s"' % fd.prefixed_name
        where_items.append(fd.key_operator.get_sql(table_field,
            prefixed_sel_field))
    where_sql = ' AND '.join(where_items)
    where_params = []
    if where[0]:
        where_sql = '(%s) AND (%s)' % (where_sql, where[0])
        where_params.extend(where[1])
    set_items, set_params = [], []
    for fd in upd_fds:
        func_sql, params = fd.set_function.get_sql(fd.get_field(model), 
            '"vals"."%s"' % fd.prefixed_name, conn, val_as_param=False)
        set_items.append(func_sql)
        set_params.extend(params)
    set_sql = ', '.join(set_items)
    query = query % ('"%s"' % db_table, set_sql, where_sql)
    return query, set_params + where_params
