| 686 | } |
| 687 | |
| 688 | void hincrbyCommand(client *c) { |
| 689 | long long value, incr, oldvalue; |
| 690 | robj *o; |
| 691 | sds newstr; |
| 692 | const unsigned char *vstr; |
| 693 | unsigned int vlen; |
| 694 | |
| 695 | if (getLongLongFromObjectOrReply(c,c->argv[3],&incr,NULL) != C_OK) return; |
| 696 | if ((o = hashTypeLookupWriteOrCreate(c,c->argv[1])) == NULL) return; |
| 697 | if (hashTypeGetValue(o,szFromObj(c->argv[2]),&vstr,&vlen,&value) == C_OK) { |
| 698 | if (vstr) { |
| 699 | if (string2ll((char*)vstr,vlen,&value) == 0) { |
| 700 | addReplyError(c,"hash value is not an integer"); |
| 701 | return; |
| 702 | } |
| 703 | } /* Else hashTypeGetValue() already stored it into &value */ |
| 704 | } else { |
| 705 | value = 0; |
| 706 | } |
| 707 | |
| 708 | oldvalue = value; |
| 709 | if ((incr < 0 && oldvalue < 0 && incr < (LLONG_MIN-oldvalue)) || |
| 710 | (incr > 0 && oldvalue > 0 && incr > (LLONG_MAX-oldvalue))) { |
| 711 | addReplyError(c,"increment or decrement would overflow"); |
| 712 | return; |
| 713 | } |
| 714 | value += incr; |
| 715 | newstr = sdsfromlonglong(value); |
| 716 | hashTypeSet(o,szFromObj(c->argv[2]),newstr,HASH_SET_TAKE_VALUE); |
| 717 | addReplyLongLong(c,value); |
| 718 | signalModifiedKey(c,c->db,c->argv[1]); |
| 719 | notifyKeyspaceEvent(NOTIFY_HASH,"hincrby",c->argv[1],c->db->id); |
| 720 | g_pserver->dirty++; |
| 721 | } |
| 722 | |
| 723 | void hincrbyfloatCommand(client *c) { |
| 724 | long double value, incr; |
nothing calls this directly
no test coverage detected