Kouhei Sutou
null+****@clear*****
Fri Jun 30 11:22:02 JST 2017
Kouhei Sutou 2017-06-30 11:22:02 +0900 (Fri, 30 Jun 2017) New Revision: 2eb37a7a5b08af5d5604b4eedf6d195ffc63a85b https://github.com/pgroonga/pgroonga/commit/2eb37a7a5b08af5d5604b4eedf6d195ffc63a85b Message: query_expand: support nonexistent case Added files: expected/function/query-expand/nonexistent.out sql/function/query-expand/nonexistent.sql Modified files: src/pgrn-query-expand.c Added: expected/function/query-expand/nonexistent.out (+10 -0) 100644 =================================================================== --- /dev/null +++ expected/function/query-expand/nonexistent.out 2017-06-30 11:22:02 +0900 (2d5d703) @@ -0,0 +1,10 @@ +CREATE TABLE synonyms ( + term text PRIMARY KEY, + synonyms text[] +); +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', 'Groonga'); + query_expand +-------------- + Groonga +(1 row) + Added: sql/function/query-expand/nonexistent.sql (+6 -0) 100644 =================================================================== --- /dev/null +++ sql/function/query-expand/nonexistent.sql 2017-06-30 11:22:02 +0900 (4166144) @@ -0,0 +1,6 @@ +CREATE TABLE synonyms ( + term text PRIMARY KEY, + synonyms text[] +); + +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', 'Groonga'); Modified: src/pgrn-query-expand.c (+9 -1) =================================================================== --- src/pgrn-query-expand.c 2017-06-30 11:14:52 +0900 (ab60984) +++ src/pgrn-query-expand.c 2017-06-30 11:22:02 +0900 (70d8c00) @@ -3,6 +3,7 @@ #include "pgrn-compatible.h" #include "pgrn-global.h" +#include "pgrn-query-expand.h" #include <access/relscan.h> #include <catalog/pg_type.h> @@ -66,11 +67,17 @@ func_query_expander_postgresql(grn_ctx *ctx, PointerGetDatum(termText)); index_rescan(currentData.scan, scanKeys, nKeys, NULL, 0); tuple = index_getnext(currentData.scan, ForwardScanDirection); + if (!tuple) + goto exit; + synonymsDatum = heap_getattr(tuple, currentData.synonymsAttribute->attnum, RelationGetDescr(currentData.table), &isNULL); - if (!isNULL) { + if (isNULL) + goto exit; + + { ArrayType *synonymsArray; int i, n; @@ -106,6 +113,7 @@ func_query_expander_postgresql(grn_ctx *ctx, rc = GRN_SUCCESS; } +exit: { grn_obj *rc_object; -------------- next part -------------- HTML����������������������������...Download