From fe7119bbc9fad0fecb88fe40119bf6d46a40bf74 Mon Sep 17 00:00:00 2001 From: yihuang Date: Sat, 11 May 2019 10:11:38 +0800 Subject: [PATCH] fix crash when query argument is not text --- redis_fdw.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/redis_fdw.c b/redis_fdw.c index f9b5775..64b1d2b 100644 --- a/redis_fdw.c +++ b/redis_fdw.c @@ -1621,22 +1621,20 @@ redisGetQual(Node *node, TupleDesc tupdesc, char **key, char **value, bool *push if (IsA(right, Const)) { - StringInfoData buf; - - initStringInfo(&buf); + if (((Const *) right)->consttype == TEXTOID) { + /* And get the column and value... */ + *key = NameStr(TupleDescAttr(tupdesc, varattno - 1)->attname); + *value = TextDatumGetCString(((Const *) right)->constvalue); - /* And get the column and value... */ - *key = NameStr(TupleDescAttr(tupdesc, varattno - 1)->attname); - *value = TextDatumGetCString(((Const *) right)->constvalue); - - /* - * We can push down this qual if: - The operatory is TEXTEQ - The - * qual is on the key column - */ - if (op->opfuncid == PROCID_TEXTEQ && strcmp(*key, "key") == 0) - *pushdown = true; + /* + * We can push down this qual if: - The operatory is TEXTEQ - The + * qual is on the key column + */ + if (op->opfuncid == PROCID_TEXTEQ && strcmp(*key, "key") == 0) + *pushdown = true; - return; + return; + } } }