• meir@redislabs.com's avatar
    Fix RM_ScanKey module api not to return int encoded strings · a89bf734
    meir@redislabs.com authored
    The scan key module API provides the scan callback with the current
    field name and value (if it exists). Those arguments are RedisModuleString*
    which means it supposes to point to robj which is encoded as a string.
    Using createStringObjectFromLongLong function might return robj that
    points to an integer and so break a module that tries for example to
    use RedisModule_StringPtrLen on the given field/value.
    
    The PR introduces a fix that uses the createObject function and sdsfromlonglong function.
    Using those function promise that the field and value pass to the to the
    scan callback will be Strings.
    
    The PR also changes the Scan test module to use RedisModule_StringPtrLen
    to catch the issue. without this, the issue is hidden because
    RedisModule_ReplyWithString knows to handle integer encoding of the
    given robj (RedisModuleString).
    
    The PR also introduces a new test to verify the issue is solved.
    a89bf734
module.c 310 KB