Skip to content

Commit

Permalink
See RED-47209, fix crash when using WITHSORTKEYS without SORTBY (#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeirShpilraien committed Sep 22, 2020
1 parent afbc834 commit 11a6218
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aggregate/aggregate_exec.c
Expand Up @@ -14,7 +14,7 @@ static void runCursor(RedisModuleCtx *outputCtx, Cursor *cursor, size_t num);
* RLookup registry. Returns NULL if there is no sorting key
*/
static const RSValue *getSortKey(AREQ *req, const SearchResult *r, const PLN_ArrangeStep *astp) {
if (!astp) {
if (!astp || !(astp->sortkeysLK)) {
return NULL;
}
const RLookupKey *kk = astp->sortkeysLK[0];
Expand Down
6 changes: 6 additions & 0 deletions src/pytest/test.py
Expand Up @@ -3155,6 +3155,12 @@ def testEmptyDoc(env):
conn.execute_command('DEL', 'doc3')
env.expect('FT.SEARCH idx *').equal([2L, 'doc4', ['t', 'foo'], 'doc2', ['t', 'foo']])

def testRED47209(env):
conn = getConnectionByEnv(env)
env.expect('FT.CREATE idx SCHEMA t TEXT').ok()
conn.execute_command('hset', 'doc1', 't', 'foo')
env.expect('FT.SEARCH idx foo WITHSORTKEYS LIMIT 0 1').equal([1L, 'doc1', None, ['t', 'foo']])

def testInvertedIndexWasEntirelyDeletedDuringCursor():
env = Env(moduleArgs='GC_POLICY FORK FORK_GC_CLEAN_THRESHOLD 1')

Expand Down
2 changes: 1 addition & 1 deletion srcutil/code_style.py
Expand Up @@ -106,7 +106,7 @@
rv = po.wait()
if rv != 0:
print('Warning: Could not analyze {}'.format(f))
count = len([line for line in output.split('\n') if line])
count = len([line for line in output.decode("utf-8").split('\n') if line])
has_changes = count > 3
if options.dry_run:
if has_changes:
Expand Down

0 comments on commit 11a6218

Please sign in to comment.