Skip to content

Commit

Permalink
Fix for SELECT from set where member = membername
Browse files Browse the repository at this point in the history
A matching member value was not being returned when a match was available.
  • Loading branch information
l-d-x committed Aug 15, 2020
1 parent 7d32b93 commit 1ffe157
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions redis_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ dump_reply(redisReply *r, int level)

DEBUG((DEBUG_LEVEL,
" Reply: %s%s len(%u) str(%s) int(%lld) elements(%lu)",
prefix, reply_type_str(r->type), (unsigned)r->len, r->str,
r->integer, r->elements));
prefix, reply_type_str(r->type), (unsigned)r->len,
r->str ? r->str : "", r->integer, r->elements));
if (r->elements > 0) {
for (i = 0; i < r->elements; i++) {
elem = r->element[i];
Expand Down Expand Up @@ -2948,12 +2948,12 @@ redisIterateForeignScan(ForeignScanState *node)
ERR_CLEANUP(rctx->r_reply, rctx->r_ctx,
(ERROR, "redis error: %s", rctx->r_reply->str));
}

dump_reply(rctx->r_reply, 0);
} else {
ereport(ERROR,
(errcode(ERRCODE_FDW_ERROR), errmsg("redis null reply")));
}

dump_reply(rctx->r_reply, 0);
}

/* initialize virtual tuple */
Expand Down Expand Up @@ -3013,10 +3013,10 @@ redisIterateForeignScan(ForeignScanState *node)

case REDIS_SISMEMBER:
redis_get_reply(reply, &s_value, &i_value, &nil_value);
if (!nil_value)
nil_value = (i_value != 0);
else
s_value = rctx->where_conds.s_value;

/* If no match, then set nil_value to true */
nil_value = (i_value == 0);
s_value = rctx->where_conds.s_value;
rctx->rowcount--;
rctx->rowsdone++;
break;
Expand Down
1 change: 1 addition & 0 deletions sql/redis_fdw.sql
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ SELECT * FROM rft_list WHERE key = 'lkey';

DELETE FROM rft_set WHERE key = 'skey' AND member = 'member2';
SELECT * FROM rft_set WHERE key = 'skey' ORDER BY member;
SELECT * FROM rft_set WHERE key = 'skey' AND member = 'member3';

DELETE FROM rft_zset WHERE key = 'zkey' AND member = 'member3';
SELECT * FROM rft_zset WHERE key = 'zkey';
Expand Down

0 comments on commit 1ffe157

Please sign in to comment.