| 674 | } |
| 675 | |
| 676 | void appendCommand(client *c) { |
| 677 | size_t totlen; |
| 678 | robj *o, *append; |
| 679 | |
| 680 | o = lookupKeyWrite(c->db,c->argv[1]); |
| 681 | if (o == NULL) { |
| 682 | /* Create the key */ |
| 683 | c->argv[2] = tryObjectEncoding(c->argv[2]); |
| 684 | dbAdd(c->db,c->argv[1],c->argv[2]); |
| 685 | incrRefCount(c->argv[2]); |
| 686 | totlen = stringObjectLen(c->argv[2]); |
| 687 | } else { |
| 688 | /* Key exists, check type */ |
| 689 | if (checkType(c,o,OBJ_STRING)) |
| 690 | return; |
| 691 | |
| 692 | /* "append" is an argument, so always an sds */ |
| 693 | append = c->argv[2]; |
| 694 | if (checkStringLength(c,stringObjectLen(o),sdslen((sds)ptrFromObj(append))) != C_OK) |
| 695 | return; |
| 696 | |
| 697 | /* Append the value */ |
| 698 | o = dbUnshareStringValue(c->db,c->argv[1],o); |
| 699 | o->m_ptr = sdscatlen((sds)ptrFromObj(o),ptrFromObj(append),sdslen((sds)ptrFromObj(append))); |
| 700 | totlen = sdslen((sds)ptrFromObj(o)); |
| 701 | } |
| 702 | signalModifiedKey(c,c->db,c->argv[1]); |
| 703 | notifyKeyspaceEvent(NOTIFY_STRING,"append",c->argv[1],c->db->id); |
| 704 | g_pserver->dirty++; |
| 705 | addReplyLongLong(c,totlen); |
| 706 | } |
| 707 | |
| 708 | void strlenCommand(client *c) { |
| 709 | robj_roptr o; |
nothing calls this directly
no test coverage detected