Navigation Menu

Skip to content

Commit

Permalink
Fix _sum setter
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 19, 2015
1 parent 3fd7b27 commit a881995
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/db.c
Expand Up @@ -5846,9 +5846,16 @@ grn_accessor_set_value(grn_ctx *ctx, grn_accessor *a, grn_id id,
grn_obj_get_value(ctx, a->obj, id, &buf);
{
grn_rset_recinfo *ri = (grn_rset_recinfo *)GRN_BULK_HEAD(&buf);
int64_t *sum;
sum = grn_rset_recinfo_get_sum_(ctx, ri, a->obj);
vp = sum;
if (value->header.type == GRN_DB_INT64) {
grn_rset_recinfo_set_sum(ctx, ri, a->obj, GRN_INT64_VALUE(value));
} else {
grn_obj value_int64;
GRN_INT64_INIT(&value_int64, 0);
if (!grn_obj_cast(ctx, value, &value_int64, GRN_FALSE)) {
grn_rset_recinfo_set_sum(ctx, ri, a->obj,
GRN_INT64_VALUE(&value_int64));
}
}
}
break;
case GRN_ACCESSOR_GET_COLUMN_VALUE :
Expand Down
4 changes: 4 additions & 0 deletions lib/grn_rset.h
Expand Up @@ -70,6 +70,10 @@ int64_t *grn_rset_recinfo_get_sum_(grn_ctx *ctx,
int64_t grn_rset_recinfo_get_sum(grn_ctx *ctx,
grn_rset_recinfo *ri,
grn_obj *table);
void grn_rset_recinfo_set_sum(grn_ctx *ctx,
grn_rset_recinfo *ri,
grn_obj *table,
int64_t sum);

#ifdef __cplusplus
}
Expand Down
16 changes: 16 additions & 0 deletions lib/rset.c
Expand Up @@ -139,3 +139,19 @@ grn_rset_recinfo_get_sum(grn_ctx *ctx,
return 0;
}
}

void
grn_rset_recinfo_set_sum(grn_ctx *ctx,
grn_rset_recinfo *ri,
grn_obj *table,
int64_t sum)
{
int64_t *sum_address;

sum_address = grn_rset_recinfo_get_sum_(ctx, ri, table);
if (!sum_address) {
return;
}

*sum_address = sum;
}

0 comments on commit a881995

Please sign in to comment.