| 641 | } |
| 642 | |
| 643 | void incrbyfloatCommand(client *c) { |
| 644 | long double incr, value; |
| 645 | robj *o, *newObj; |
| 646 | |
| 647 | o = lookupKeyWrite(c->db,c->argv[1]); |
| 648 | if (checkType(c,o,OBJ_STRING)) return; |
| 649 | if (getLongDoubleFromObjectOrReply(c,o,&value,NULL) != C_OK || |
| 650 | getLongDoubleFromObjectOrReply(c,c->argv[2],&incr,NULL) != C_OK) |
| 651 | return; |
| 652 | |
| 653 | value += incr; |
| 654 | if (std::isnan(value) || std::isinf(value)) { |
| 655 | addReplyError(c,"increment would produce NaN or Infinity"); |
| 656 | return; |
| 657 | } |
| 658 | newObj = createStringObjectFromLongDouble(value,1); |
| 659 | if (o) |
| 660 | dbOverwrite(c->db,c->argv[1],newObj); |
| 661 | else |
| 662 | dbAdd(c->db,c->argv[1],newObj); |
| 663 | signalModifiedKey(c,c->db,c->argv[1]); |
| 664 | notifyKeyspaceEvent(NOTIFY_STRING,"incrbyfloat",c->argv[1],c->db->id); |
| 665 | g_pserver->dirty++; |
| 666 | addReplyBulk(c,newObj); |
| 667 | |
| 668 | /* Always replicate INCRBYFLOAT as a SET command with the final value |
| 669 | * in order to make sure that differences in float precision or formatting |
| 670 | * will not create differences in replicas or after an AOF restart. */ |
| 671 | rewriteClientCommandArgument(c,0,shared.set); |
| 672 | rewriteClientCommandArgument(c,2,newObj); |
| 673 | rewriteClientCommandArgument(c,3,shared.keepttl); |
| 674 | } |
| 675 | |
| 676 | void appendCommand(client *c) { |
| 677 | size_t totlen; |
nothing calls this directly
no test coverage detected