| 87 | }; |
| 88 | |
| 89 | robj *fetchFromKey(redisDb *db, robj_roptr key) { |
| 90 | const char *pchCur = szFromObj(key); |
| 91 | const char *pchStart = pchCur; |
| 92 | const char *pchMax = pchCur + sdslen(pchCur); |
| 93 | robj *o = nullptr; |
| 94 | |
| 95 | while (pchCur <= pchMax) { |
| 96 | if (pchCur == pchMax || *pchCur == '.') { |
| 97 | // WARNING: Don't deref pchCur as it may be pchMax |
| 98 | |
| 99 | // New word |
| 100 | if ((pchCur - pchStart) < 1) { |
| 101 | throw shared.syntaxerr; // malformed |
| 102 | } |
| 103 | |
| 104 | DbDictWrapper srcDb; |
| 105 | if (o == nullptr) |
| 106 | srcDb = db; |
| 107 | else |
| 108 | srcDb = (dict*)ptrFromObj(o); |
| 109 | |
| 110 | sdsstring str(pchStart, pchCur - pchStart); |
| 111 | o = srcDb.find(str.get()).val(); |
| 112 | |
| 113 | if (o == nullptr) throw shared.nokeyerr; // Not Found |
| 114 | serverAssert(o->type == OBJ_NESTEDHASH || o->type == OBJ_STRING || o->type == OBJ_LIST); |
| 115 | if (o->type == OBJ_STRING && pchCur != pchMax) |
| 116 | throw shared.nokeyerr; // Past the end |
| 117 | |
| 118 | pchStart = pchCur + 1; |
| 119 | } |
| 120 | ++pchCur; |
| 121 | } |
| 122 | |
| 123 | return o; |
| 124 | } |
| 125 | |
| 126 | // Returns one if we overwrote a value |
| 127 | bool setWithKey(redisDb *db, robj_roptr key, robj *val, bool fCreateBuckets) { |
no test coverage detected